示例#1
0
        public void CreateHash_NullInput_Throws()
        {
            // Arrange
            var algorithm = new SHA384();

            // Act && Assert
            Assert.Throws <ArgumentNullException>(() => algorithm.CreateHash(null));
        }
示例#2
0
        public void IsThisAlgorithm_ValidInput_ReturnsTrue()
        {
            // Arrange
            var algorithm = new SHA384();

            // Act
            var hash            = algorithm.CreateHash("Hello world");
            var isThisAlgorithm = algorithm.IsThisAlgorithm(hash);

            // Assert
            Assert.True(isThisAlgorithm);
        }
示例#3
0
        public void CreateHash_ProperInput_Hashes()
        {
            // Arrange
            var algorithm = new SHA384();

            // Act
            var hash = algorithm.CreateHash("Hello world");

            // Assert
            Assert.NotNull(hash);
            Assert.Equal(algorithm.HashLength, hash.Length);
        }
示例#4
0
        public void CreateHash_EmptyInput_Hashes()
        {
            // Arrange
            var algorithm = new SHA384();

            // Act
            var hash = algorithm.CreateHash(string.Empty);

            // Assert
            Assert.NotNull(hash);
            Assert.Equal(algorithm.HashLength, hash.Length);
        }
示例#5
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);
        }
示例#6
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);
        }