예제 #1
0
        public void ValidateStreamContents()
        {
            byte[]    result;
            const int ByteCount = 1026;

            using (var stream = new PositionValueStream(ByteCount))
                using (HashAlgorithm hash = new Sum32Hash())
                {
                    result = hash.ComputeHash(stream);
                }

            AssertCorrectAnswer(ExpectedSum(0, ByteCount), result);
        }
예제 #2
0
        private void ValidateOffset(int arraySize, int hashOffset, int hashCount)
        {
            byte[] input;

            using (var stream = new PositionValueStream(arraySize))
                using (var reader = new BinaryReader(stream))
                {
                    input = reader.ReadBytes(arraySize);
                }

            byte[] result;

            using (HashAlgorithm hash = new Sum32Hash())
            {
                result = hash.ComputeHash(input, hashOffset, hashCount);
            }

            uint expectedSum = ExpectedSum(hashOffset, hashCount);

            AssertCorrectAnswer(expectedSum, result);
        }