Beispiel #1
0
        public void WriteToStreamAndToByteArrayIsEquivalent()
        {
            var h1           = new Md5Hash(1, 2, 3, 4);
            var memoryStream = new MemoryStream();

            h1.Write(memoryStream);
            var arrayFromStram = memoryStream.ToArray();
            var array          = h1.ToByteArray();

            CollectionAssert.AreEqual(arrayFromStram, array);
        }
Beispiel #2
0
        public void WriteToBinaryWriterAndToByteArrayIsEquivalent()
        {
            var h1           = new Md5Hash(1, 2, 3, 4);
            var memoryStream = new MemoryStream();

            using (var writer = new BinaryWriter(memoryStream))
                h1.Write(writer);
            var arrayFromStram = memoryStream.ToArray();
            var array          = h1.ToByteArray();

            CollectionAssert.AreEqual(arrayFromStram, array);
        }
Beispiel #3
0
        public void WritenAndReadedIsEquivalent()
        {
            var h1           = new Md5Hash(1, 2, 3, 4);
            var memoryStream = new MemoryStream();

            using (var writer = new BinaryWriter(memoryStream))
                h1.Write(writer);
            var arrayFromStram = memoryStream.ToArray();

            memoryStream = new MemoryStream(arrayFromStram);
            Md5Hash h2 = new Md5Hash();

            using (var reader = new BinaryReader(memoryStream))
                h2 = Md5Hash.Read(reader);
            var array = h1.ToByteArray();

            Assert.That(h1.A, Is.EqualTo(h2.A));
            Assert.That(h1.B, Is.EqualTo(h2.B));
            Assert.That(h1.C, Is.EqualTo(h2.C));
            Assert.That(h1.D, Is.EqualTo(h2.D));
        }