예제 #1
0
        public void Should_compute_for_stream_values(IChecksumImplementation impl, string expectedChecksum)
        {
            byte[] sourceBytes = Encoding.ASCII.GetBytes("CodeBits");
            var    ms          = new MemoryStream(sourceBytes);
            string checksum    = impl.FromStream(ms);

            checksum.ShouldBe(expectedChecksum);
        }
예제 #2
0
        public void Should_throw_if_file_not_found(IChecksumImplementation impl)
        {
            Should.Throw <FileNotFoundException>(() => impl.FromFile(string.Empty));
            Should.Throw <FileNotFoundException>(() => impl.FromFile(string.Empty, 4096));

            Should.Throw <FileNotFoundException>(() => impl.FromFile(@"Z:\should_not_exist.txt"));
            Should.Throw <FileNotFoundException>(() => impl.FromFile(@"Z:\should_not_exist.txt", 4096));
        }
예제 #3
0
 public void Should_throw_for_null_values(IChecksumImplementation impl)
 {
     Should.Throw <ArgumentNullException>(() => impl.FromBytes(null));
     Should.Throw <ArgumentNullException>(() => impl.FromFile(null));
     Should.Throw <ArgumentNullException>(() => impl.FromFile(null, 4096));
     Should.Throw <ArgumentNullException>(() => impl.FromStream(null));
     Should.Throw <ArgumentNullException>(() => impl.FromString(null));
 }
예제 #4
0
        public void Should_compute_for_string_values(IChecksumImplementation impl, string expectedChecksum)
        {
            string checksum = impl.FromString("CodeBits");

            checksum.ShouldBe(expectedChecksum);
        }
예제 #5
0
        public void Empty_byte_array_checksum_should_be_same_as_empty_string_checksum(IChecksumImplementation impl)
        {
            string emptyByteArray = impl.FromBytes(new byte[0]);
            string emptyString    = impl.FromString(string.Empty);

            emptyByteArray.ShouldBe(emptyString);
        }