Esempio n. 1
0
        public void ValidateHash_NullInput_Throws()
        {
            // Arrange
            var algorithm = new SHA384();

            // Act && Assert
            Assert.Throws <ArgumentNullException>(() => algorithm.ValidateHash(null, "not an SHA384 hash"));
            Assert.Throws <ArgumentNullException>(() => algorithm.ValidateHash("Hello world", null));
        }
Esempio n. 2
0
        public void ValidateHash_InvalidCorrectHash_Throws()
        {
            // Arrange
            var algorithm = new SHA384();

            // Act && Assert
            Assert.Throws <ArgumentException>(() => algorithm.ValidateHash("Hello world", "not an SHA384 hash"));
        }
Esempio n. 3
0
        public void ValidateHash_MatchingHash_ReturnsTrue()
        {
            // Arrange
            var algorithm = new SHA384();

            // Act
            var helloWorldHash = algorithm.CreateHash("Hello world");
            var validHash      = algorithm.ValidateHash("Hello world", helloWorldHash);

            // Assert
            Assert.True(validHash);
        }
Esempio n. 4
0
        public void ValidateHash_NotMatchingHash_ReturnsFalse()
        {
            // Arrange
            var algorithm = new SHA384();

            // Act
            var helloWorldHash = algorithm.CreateHash("Hello world");
            var validHash      = algorithm.ValidateHash("Definately not hello world", helloWorldHash);

            // Assert
            Assert.False(validHash);
        }