示例#1
0
        public void op_Compute_stringEmpty_Encoding()
        {
            MD5Hash expected = Convert.FromBase64String(_emptyHash);
            var     actual   = MD5Hash.Compute(string.Empty, Encoding.Default);

            Assert.Equal(expected, actual);
        }
示例#2
0
        public void op_Compute_string_Encoding()
        {
            MD5Hash expected = Convert.FromBase64String(_jigsawHash);
            var     actual   = MD5Hash.Compute(_jigsawHtml, Encoding.Default);

            Assert.Equal(expected, actual);
        }
示例#3
0
        public void op_Compute_byte()
        {
            MD5Hash expected = Convert.FromBase64String(_jigsawHash);
            var     actual   = MD5Hash.Compute(Encoding.Default.GetBytes(_jigsawHtml));

            Assert.Equal(expected, actual);
        }
示例#4
0
        public void op_Compute_FileSystemInfoEmpty()
        {
            MD5Hash expected = Convert.FromBase64String(_emptyHash);
            var     actual   = MD5Hash.Compute(new FileInfo(@"Security\Cryptography\empty.html"));

            Assert.Equal(expected, actual);
        }
示例#5
0
        public void op_Compute_byteEmpty()
        {
            MD5Hash expected = Convert.FromBase64String(_emptyHash);
            var     actual   = MD5Hash.Compute(new byte[]
            {
            });

            Assert.Equal(expected, actual);
        }
示例#6
0
        public void op_Compute_streamEmpty()
        {
            MD5Hash expected = Convert.FromBase64String(_emptyHash);
            MD5Hash actual;

            using (var stream = new MemoryStream())
            {
                actual = MD5Hash.Compute(stream);
            }

            Assert.Equal(expected, actual);
        }
示例#7
0
        public void op_Compute_Uri()
        {
            try
            {
                MD5Hash expected = Convert.FromBase64String(_jigsawHash);
                var     actual   = MD5Hash.Compute(new Uri("http://jigsaw.w3.org/HTTP/h-content-md5.html"));

                Assert.Equal(expected, actual);
            }
            catch (SocketException)
            {
            }
        }
示例#8
0
        public void op_Compute_stream()
        {
            MD5Hash expected = Convert.FromBase64String(_jigsawHash);
            MD5Hash actual;

            using (var stream = new MemoryStream())
            {
                using (var writer = new StreamWriter(stream))
                {
                    writer.Write(_jigsawHtml);
                    writer.Flush();
                    stream.Position = 0;

                    actual = MD5Hash.Compute(stream);
                }
            }

            Assert.Equal(expected, actual);
        }
示例#9
0
 public void op_Compute_string_EncodingNull()
 {
     Assert.Throws <ArgumentNullException>(() => MD5Hash.Compute("test", null));
 }
示例#10
0
 public void op_Compute_stringNull_Encoding()
 {
     Assert.Throws <ArgumentNullException>(() => MD5Hash.Compute(null, Encoding.Default));
 }
示例#11
0
 public void op_Compute_stringNull()
 {
     Assert.Throws <ArgumentNullException>(() => MD5Hash.Compute(null as string));
 }
示例#12
0
 public void op_Compute_byteNull()
 {
     Assert.Throws <ArgumentNullException>(() => MD5Hash.Compute(null as byte[]));
 }
示例#13
0
 public void op_Compute_UriNull()
 {
     Assert.Throws <ArgumentNullException>(() => MD5Hash.Compute(null as Uri));
 }
示例#14
0
 public void op_Compute_FileSystemInfoNull()
 {
     Assert.Throws <ArgumentNullException>(() => MD5Hash.Compute(null as FileSystemInfo));
 }