Ejemplo n.º 1
0
		public void Correctly_provides_feedback_if_login_is_unsuccessful()
		{
			MockRepository mocks = new MockRepository();
			ILoginChecker checker = mocks.CreateMock<ILoginChecker>();
			IAuthenticationService authenticationService = mocks.CreateMock<IAuthenticationService>();
			ISystemUserRepository repository = mocks.CreateMock<ISystemUserRepository>();

			using (mocks.Record())
			{
				Expect.Call(checker.IsValidUser("*****@*****.**", "pass", repository)).Return(false);
			}

			using (mocks.Playback())
			{
				ILoginService loginService = new LoginService(checker, authenticationService, null);
				string userFeedback = loginService.Login("*****@*****.**", "pass", false, repository);

				Assert.That(userFeedback, Is.EqualTo("Invalid e-mail address/password: Please try again"));
			}

			mocks.VerifyAll();
		}
Ejemplo n.º 2
0
		public void Correctly_redirects_from_login_page_when_valid_login_is_entered()
		{
			MockRepository mocks = new MockRepository();
			ILoginChecker checker = mocks.CreateMock<ILoginChecker>();
			IAuthenticationService authenticationService = mocks.CreateMock<IAuthenticationService>();
			ISystemUserRepository repository = mocks.CreateMock<ISystemUserRepository>();

			using (mocks.Record())
			{
				Expect.Call(checker.IsValidUser("*****@*****.**", "pass", repository)).Return(true);
				authenticationService.RedirectFromLoginPage("*****@*****.**", true);
			}

			using (mocks.Playback())
			{
				ILoginService loginService = new LoginService(checker, authenticationService, null);
				string userFeedback = loginService.Login("*****@*****.**", "pass", true, repository);

				Assert.That(userFeedback, Is.Null);
			}

			mocks.VerifyAll();
		}