public void TestVerifyPasswordReturnTrueWhenCorrect() { var hashed = PasswordUtils.Hashpassword("aaa"); Assert.NotEqual(hashed, "aaa"); Assert.True(PasswordUtils.Verify(hashed, "aaa")); }
public LoginServiceTest() { var dbOptions = new DbContextOptionsBuilder <MvcTodoContext>().UseInMemoryDatabase("test").Options; var dbContext = new MvcTodoContext(dbOptions); var repo = new MvcTodo.Repo.UserRepo(dbContext); dbContext.Users.RemoveRange(dbContext.Users); dbContext.Users.Add(new User() { Username = "******", Password = PasswordUtils.Hashpassword("test") }); dbContext.SaveChanges(); this.service = new MvcTodo.Services.AuthService(repo); }
public void TestVerifyPasswordReturnFalseWhenIncorrect() { var hashed = PasswordUtils.Hashpassword("aaa"); Assert.False(PasswordUtils.Verify(hashed, "aaa22")); }