예제 #1
0
        public void CreateHash_NullInput_Throws()
        {
            // Arrange
            var algorithm = new SHA1();

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

            // 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 SHA1();

            // 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 SHA1();

            // 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 SHA1();

            // 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 SHA1();

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

            // Assert
            Assert.False(validHash);
        }