public void ValidateUser_Returns_False_For_Used_Email() { //Arrange User user = GetValidUserObject(); user.Email = "*****@*****.**"; var foundUser = new FakeUser { Email = user.Email }; foundUser.SetId(3); var userList = new List<User> { foundUser }.AsQueryable(); var validationDictionary = new ModelStateWrapper(ModelState); var userRepository = new Mock<IUserRepository>(); userRepository.Setup(u => u.FindAll()).Returns(userList); var userService = ServiceMiniMart.CreateUserService(userRepository); //Act userService.ValidateUser(user, validationDictionary); //Assert var errorList = validationDictionary.Errors.Aggregate(string.Empty, (current, error) => current + error.Message + "; "); Assert.IsFalse(validationDictionary.IsValid, errorList); }
public FakeContext() { User = new FakeUser { Username = "******" }; }