public void CreateUser_UserDoesExist_ReturnsFalse() { byte[] salt = PasswordManagement.GenerateSalt(); byte[] pass = PasswordManagement.GenerateSaltedPassword(Encoding.UTF8.GetBytes("Password"), salt); var mock = new Mock<IUnitOfWork>(); mock.Setup(u => u.UserRepository.Get(It.IsAny<Expression<Func<User, bool>>>(), null, "")).Returns( new List<User> { new User { UserId = 4, FirstName = "Test4", LastName = "LastName", Email = "*****@*****.**", Salt = salt, Password = pass }, }); RegisterService registerService = new RegisterService(mock.Object); UserDTO testUser = new UserDTO(); testUser.Email = "*****@*****.**"; bool result = registerService.createNewUser(testUser); Assert.IsFalse(result); }