Beispiel #1
0
        public async void AuthenticatorLoginShouldNotLoginWhenServiceReturnsNull()
        {
            User user = null;

            LoginAttempt attempt = new LoginAttempt(user);

            LoginModel model = new LoginModel();

            model.Login    = "******";
            model.Password = "******";

            ILoginService        service = MockRepository.GenerateStub <ILoginService>();
            ISessionHelper       session = MockRepository.GenerateStub <ISessionHelper>();
            IFormsAuthentication forms   = MockRepository.GenerateStub <IFormsAuthentication>();

            service.Stub(s => s.Login(model.Login, model.Password)).Return(Task <LoginAttempt> .FromResult(attempt));

            Authenticator authenticator = new Authenticator(service, session, forms);
            bool          result        = await authenticator.Login(model);

            Assert.IsFalse(result);
            service.AssertWasCalled(s => s.Login(model.Login, model.Password));
            session.AssertWasNotCalled(s => s.User.Id);
            forms.AssertWasNotCalled(f => f.SetAuthCookie(Arg <string> .Is.Anything, Arg <bool> .Is.Anything));
        }