public void HandmadeSerializer_Serialize_2()
        {
            MyFirstClass[] array = new MyFirstClass[0];

            HandmadeSerializer serializer = new HandmadeSerializer();
            MemoryStream       stream     = new MemoryStream();

            using (BinaryWriter writer = new BinaryWriter(stream))
            {
                // ReSharper disable once CoVariantArrayConversion
                serializer.Serialize(writer, array);
            }
        }
        public void HandmadeSerializer_Serialize_1()
        {
            MyFirstClass first1 = new MyFirstClass
            {
                FirstField = 73
            };

            HandmadeSerializer serializer = new HandmadeSerializer((PrefixLength)44);
            MemoryStream       stream     = new MemoryStream();

            using (BinaryWriter writer = new BinaryWriter(stream))
            {
                serializer.Serialize(writer, first1);
            }
        }
        public void HandmadeSerializer_Roundtrip_2()
        {
            MyFirstClass first1 = new MyFirstClass
            {
                FirstField = 73
            };
            MySecondClass second1 = new MySecondClass
            {
                SecondField = "Hello"
            };
            MyThirdClass third1 = new MyThirdClass
            {
                ThirdField  = true,
                FourthField = 123.45
            };

            HandmadeSerializer serializer = new HandmadeSerializer(PrefixLength.Short)
            {
                Namespace = "UnitTests.AM.Runtime",
                Assembly  = typeof(MyFirstClass).Assembly
            };
            MemoryStream stream = new MemoryStream();

            using (BinaryWriter writer = new BinaryWriter(stream))
            {
                serializer.Serialize(writer, first1);
                serializer.Serialize(writer, second1);
                serializer.Serialize(writer, third1);
            }

            byte[] buffer = stream.ToArray();

            stream = new MemoryStream(buffer);
            using (BinaryReader reader = new BinaryReader(stream))
            {
                MyFirstClass first2 = (MyFirstClass)serializer.Deserialize(reader);
                Assert.AreEqual(first1.FirstField, first2.FirstField);

                MySecondClass second2 = (MySecondClass)serializer.Deserialize(reader);
                Assert.AreEqual(second1.SecondField, second2.SecondField);

                MyThirdClass third2 = (MyThirdClass)serializer.Deserialize(reader);
                Assert.AreEqual(third1.ThirdField, third2.ThirdField);
                Assert.AreEqual(third1.FourthField, third2.FourthField);
            }
        }
        public void HandmadeSerializer_Roundtrip_1()
        {
            MyFirstClass first1 = new MyFirstClass
            {
                FirstField = 73
            };
            MySecondClass second1 = new MySecondClass
            {
                SecondField = "Hello"
            };
            MyThirdClass third1 = new MyThirdClass
            {
                ThirdField  = true,
                FourthField = 123.45
            };

            HandmadeSerializer serializer = new HandmadeSerializer();
            MemoryStream       stream     = new MemoryStream();

            using (BinaryWriter writer = new BinaryWriter(stream))
            {
                serializer.Serialize(writer, first1);
                serializer.Serialize(writer, second1);
                serializer.Serialize(writer, third1);
            }

            byte[] buffer = stream.ToArray();

            stream = new MemoryStream(buffer);
            using (BinaryReader reader = new BinaryReader(stream))
            {
                MyFirstClass first2 = (MyFirstClass)serializer.Deserialize(reader);
                Assert.AreEqual(first1.FirstField, first2.FirstField);

                MySecondClass second2 = (MySecondClass)serializer.Deserialize(reader);
                Assert.AreEqual(second1.SecondField, second2.SecondField);

                MyThirdClass third2 = (MyThirdClass)serializer.Deserialize(reader);
                Assert.AreEqual(third1.ThirdField, third2.ThirdField);
                Assert.AreEqual(third1.FourthField, third2.FourthField);
            }
        }