public void ValidateHash_NullInput_Throws() { // Arrange var algorithm = new PBKDF2(); // Act && Assert Assert.Throws <ArgumentNullException>(() => algorithm.ValidateHash(null, "not an PBKDF2 hash")); Assert.Throws <ArgumentNullException>(() => algorithm.ValidateHash("Hello world", null)); }
public void ValidateHash_InvalidCorrectHash_Throws() { // Arrange var algorithm = new PBKDF2(); // Act && Assert Assert.Throws <ArgumentException>(() => algorithm.ValidateHash("Hello world", "not an PBKDF2 hash")); }
public void ValidateHash_MatchingHash_ReturnsTrue() { // Arrange var algorithm = new PBKDF2(); // Act var helloWorldHash = algorithm.CreateHash("Hello world"); var validHash = algorithm.ValidateHash("Hello world", helloWorldHash); // Assert Assert.True(validHash); }
public void ValidateHash_NotMatchingHash_ReturnsFalse() { // Arrange var algorithm = new PBKDF2(); // Act var helloWorldHash = algorithm.CreateHash("Hello world"); var validHash = algorithm.ValidateHash("Definately not hello world", helloWorldHash); // Assert Assert.False(validHash); }