コード例 #1
0
        public void CreateHash_StreamSmallerThan64k_ReturnsEmptyHash(
            [Frozen] IHashCalculator hashProvider,
            FileHasher sut)
        {
            var expectedHash = new byte[0];
            var data = new byte[0];

            using (var stream = new MemoryStream(data))
            {
                var result = sut.CreateHash(stream);
                Assert.That(result, Is.EquivalentTo(expectedHash));
            }
        }
コード例 #2
0
        public void CreateHash_128kStream_ReturnsHashFromHashAlgo(
            byte[] expectedHash,
            [Frozen]IHashCalculator hashProvider,
            FileHasher sut)
        {
            var data = CreateData();
            A.CallTo(() => hashProvider.ComputeHash(
                A<byte[]>.That.IsSameSequenceAs(data)))
               .Returns(expectedHash);

            using (var stream = new MemoryStream(data))
            {
                var result = sut.CreateHash(stream);
                Assert.That(result, Is.EquivalentTo(expectedHash));
            }
        }
コード例 #3
0
 public SubDbFileHasher()
 {
     _hasher = new FileHasher(new HashCalculator<MD5CryptoServiceProvider>());
 }
コード例 #4
0
 public OpenSubtitlesFileHasher()
 {
     _hasher = new FileHasher(new OpenSubtitlesHashCalculator());
 }