コード例 #1
0
        public async void WillCallTestLoginMethodOnIsUserLoggedInAsync()
        {
            var logic = new LoginLogic(_oAuthManager, null, _tokenRepository, _userRepository, _preferencesRepository, _updateRepository);

            const string tokenString = "Some String";

            _tokenRepository.Expect(t => t.Get()).Return(new Token {
                TokenString = tokenString,
                Secret      = null
            });
            _userRepository.Expect(t => t.Get()).Return(new User());

            _oAuthManager.Expect(o => o.MakeAuthenticatedRequestAsync(null, null)).IgnoreArguments();

            var applyUser = new Action <User>(delegate { });

            await logic.IsUserLoggedInAsync(applyUser);

            _tokenRepository.VerifyAllExpectations();
            _userRepository.VerifyAllExpectations();

            Assert.Equals(_oAuthManager.AccessToken, tokenString);

            _oAuthManager.VerifyAllExpectations();
        }
コード例 #2
0
        public async Task WillCallTestLoginMethodOnIsUserLoggedInAsync()
        {
            var logic = new LoginLogic(_oAuthManager, null, null, _tokenRepository, _userRepository, _preferencesRepository,
                                       _updateRepository, _donateIntentRepo);

            const string tokenString = "Some String";

            _tokenRepository.Expect(t => t.Get()).Return(new Token
            {
                TokenString = tokenString,
                Secret      = null
            });
            _userRepository.Expect(t => t.Get()).Return(new User());

            _oAuthManager.Expect(o => o.MakeAuthenticatedRequestAsync(Arg <string> .Is.Anything, Arg <IDictionary <string, string> > .Is.Anything))
            .Return(Task.FromResult <dynamic>((dynamic) new Dictionary <string, object>()));

            var applyUser = new Action <User>(delegate { });

            await logic.IsUserLoggedInAsync(applyUser);

            _tokenRepository.VerifyAllExpectations();
            _userRepository.VerifyAllExpectations();
            _oAuthManager.VerifyAllExpectations();
        }