public void ProcessStream_returns_hashes_with_correct_rolling_sums()
        {
            MemoryStream stream = GetOriginalFileStream();
            var          gen    = new HashBlockGenerator(new RollingChecksum(), new HashAlgorithmWrapper <MD5>(MD5.Create()), BLOCK_SIZE);
            int          i      = 0;

            Assert.IsTrue(gen.ProcessStream(stream).All(x => x.Checksum == checkSums[i++]));
        }
        public void ProcessStream_returns_correct_block_count()
        {
            MemoryStream stream = GetOriginalFileStream();
            var          gen    = new HashBlockGenerator(new RollingChecksum(), new HashAlgorithmWrapper <MD5>(MD5.Create()), BLOCK_SIZE);

            Assert.AreEqual(
                Math.Ceiling(originalFile.Length / (float)BLOCK_SIZE),
                gen.ProcessStream(stream).Count());
        }
        public void ProcessStream_returns_hashes_with_correct_length()
        {
            MemoryStream stream = GetOriginalFileStream();
            var          gen    = new HashBlockGenerator(new RollingChecksum(), new HashAlgorithmWrapper <MD5>(MD5.Create()), BLOCK_SIZE);
            int          i      = 0;

            Assert.IsTrue(gen.ProcessStream(stream).All(x =>
                                                        x.Length ==
                                                        Math.Min(BLOCK_SIZE, originalFile.Length - i++ *BLOCK_SIZE)));
        }
        public void ProcessStream_returns_hashes_with_correct_md5_sums()
        {
            MemoryStream stream = GetOriginalFileStream();
            var          gen    = new HashBlockGenerator(new RollingChecksum(), new HashAlgorithmWrapper <MD5>(MD5.Create()), BLOCK_SIZE);
            int          i      = 0;

            Assert.IsTrue(gen.ProcessStream(stream).All(x =>
                                                        BitConverter.ToString(x.Hash)
                                                        .Replace("-", "")
                                                        .ToLower()
                                                        .Equals(md5sums[i++].ToLower())
                                                        ));
        }
        public void ProcessStream_throws_for_null_stream()
        {
            var gen = new HashBlockGenerator(new RollingChecksum(), new HashAlgorithmWrapper <MD5>(MD5.Create()), BLOCK_SIZE);

            gen.ProcessStream(null).Count();
        }