public void VerifyPassword_ComparingWrongPassword_ShouldNotBeEqual() { // Arrange HashingSettings settings = new HashingSettings(HashingMethodType.SHA256); HashingService hashingService = new HashingService(settings); string username = "******"; string correctPassword = "******"; string wrongPassword = "******"; IHashedUser hashedUser = null; bool passwordMatched = false; // Act hashedUser = hashingService.CreateHashedUser(username, correctPassword); passwordMatched = hashingService.VerifyPassword(wrongPassword, hashedUser.Password, hashedUser.Salt); Console.WriteLine("Original Correct Password: "******"Original Wrong Password: "******"Hashed Password: "******"Hashed Salt: " + hashedUser.Salt); // Assert Assert.IsFalse(passwordMatched); }
public void CreateHashedUser_WithInvalidSettings_ShouldThrowException() { // Arrange HashingSettings settings = new HashingSettings(HashingMethodType.SHA256); HashingService hashingService = new HashingService(settings); string username = "******"; string password = null; // Act and Assert Assert.ThrowsException <System.ArgumentNullException>(() => hashingService.CreateHashedUser(username, password)); }
public void CreateHashedUser_WithValidSettings_ShouldCreateIHashedUser() { // Arrange HashingSettings settings = new HashingSettings(HashingMethodType.SHA256); HashingService hashingService = new HashingService(settings); string username = "******"; string password = "******"; IHashedUser hashedUser = null; // Act hashedUser = hashingService.CreateHashedUser(username, password); // Assert Assert.IsNotNull(hashedUser); }