Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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));
            }
        }