public void SignInPost_ValidUser_Redirects() { var model = new SignInViewModel { Username = "******", Password = "******", RememberMe = false, }; var fakeVolunteer = new Volunteer { Username = model.Username, Password = model.Password, Active = true, }; var formsAuthenticationServiceMock = new Mock<IFormsAuthenticationService>(); formsAuthenticationServiceMock.Setup(f => f.SetAuthCookie(It.IsAny<Volunteer>(), It.IsAny<bool>())) .Verifiable(); var volunteerDataServiceMock = new Mock<IDataService<Volunteer>>(); volunteerDataServiceMock.Setup(v => v.SelectOne(It.IsAny<Expression<Func<Volunteer, bool>>>())) .Returns(fakeVolunteer); volunteerDataServiceMock.Setup(v => v.HashPassword(It.IsAny<string>())) .Returns(model.Password); volunteerDataServiceMock.Setup(v => v.VerifyPassword(It.IsAny<string>(), It.IsAny<string>())) .Returns(true); var accountController = new AccountController( formsAuthenticationServiceMock.Object, volunteerDataServiceMock.Object); ActionResult result = accountController.SignIn(model, "home/index"); Assert.IsInstanceOf<RedirectResult>(result); }
public void SignIn_ReturnsView() { var accountController = new AccountController( new Mock<IFormsAuthenticationService>().Object, new Mock<IDataService<Volunteer>>().Object); ActionResult result = accountController.SignIn(); Assert.IsInstanceOf<ViewResult>(result); }
public void SignInPost_InvalidModelState_ReturnsView() { var accountController = new AccountController( new Mock<IFormsAuthenticationService>().Object, new Mock<IDataService<Volunteer>>().Object); accountController.ModelState.AddModelError("test", "error"); var model = new SignInViewModel(); ActionResult result = accountController.SignIn(model, "home/index"); Assert.IsInstanceOf<ViewResult>(result); }