public void ConfirmUser_InvalidCode_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>()); RegisterService registerService = new RegisterService(mock.Object); bool result = registerService.ConfirmUser("code"); Assert.IsFalse(result); }
public void ConfirmUser_ValidCode_ReturnsTrue() { 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, ConfirmCode = "code", AccountConfirmed = false }, }); RegisterService registerService = new RegisterService(mock.Object); bool result = registerService.ConfirmUser("code"); Assert.IsTrue(result); }