public void WhenUserExistsValidationSucceeds() { Mock<IUserService> sessionMock = new Mock<IUserService>(); sessionMock.Setup(x => x.DoesUserExistWithUsernameAndPassword("test", "pass")).Returns(true); UserSignInViewModelValidator validator = new UserSignInViewModelValidator(sessionMock.Object); var results = validator.Validate(new ViewModels.UserSignInViewModel() { Username = "******", Password = "******", StayLoggedIn = true }); Assert.True(results.IsValid); }
public void WhenUserDoesNotExistValidationFails() { Mock <IUserService> sessionMock = new Mock <IUserService>(); sessionMock.Setup(x => x.DoesUserExistWithUsernameAndPassword("test", "pass")).Returns(false); UserSignInViewModelValidator validator = new UserSignInViewModelValidator(sessionMock.Object); var results = validator.Validate(new ViewModels.UserSignInViewModel() { Username = "******", Password = "******", StayLoggedIn = true }); Assert.False(results.IsValid); }