public void TestThereAndBackAgain()
        {
            var inputTopLevel = new TestTopLevel();

            inputTopLevel.SubComp            = new TestSubComp();
            inputTopLevel.SubComp.Byte1      = 101;
            inputTopLevel.SubComp.Byte2      = 202;
            inputTopLevel.SubFixed           = new TestSubFixed();
            inputTopLevel.SubFixed[2]        = 1234123412341234;
            inputTopLevel.SubGroup           = new TestSubGroup();
            inputTopLevel.SubGroup.Type      = TestSubGroupType.TestSubGroupTypeVariable;
            inputTopLevel.SubGroup.SubVar    = new TestSubVariable(3);
            inputTopLevel.SubGroup.SubVar[1] = 55;
            inputTopLevel.SubInt             = 1000000;

            var formatter = new CauterizeFormatter();
            var stream    = new MemoryStream(2048);

            formatter.Serialize(stream, inputTopLevel);

            stream.Position = 0;
            var outputTopLevel = formatter.Deserialize <TestTopLevel>(stream);

            Assert.AreEqual(inputTopLevel.SubComp.Byte1, outputTopLevel.SubComp.Byte1);
            Assert.AreEqual(inputTopLevel.SubComp.Byte2, outputTopLevel.SubComp.Byte2);
            Assert.AreEqual(inputTopLevel.SubFixed[0], outputTopLevel.SubFixed[0]);
            Assert.AreEqual(inputTopLevel.SubFixed[2], outputTopLevel.SubFixed[2]);
            Assert.AreEqual(inputTopLevel.SubGroup.Type, outputTopLevel.SubGroup.Type);
            Assert.AreEqual(inputTopLevel.SubGroup.SubVar[0], outputTopLevel.SubGroup.SubVar[0]);
            Assert.AreEqual(inputTopLevel.SubGroup.SubVar[1], outputTopLevel.SubGroup.SubVar[1]);
            Assert.AreEqual(inputTopLevel.SubInt, outputTopLevel.SubInt);
        }
 public void TestDeserialize()
 {
     var subFormatter = new Mock<ICauterizeTypeFormatter>();
     var serializationStream = new MemoryStream();
     subFormatter.Setup(sf => sf.Deserialize(serializationStream, typeof (string))).Returns("hello world");
     var factory = new Mock<CauterizeTypeFormatterFactory>();
     factory.Setup(f => f.GetFormatter(typeof (string))).Returns(subFormatter.Object);
     var formatter = new CauterizeFormatter(factory.Object);
     Assert.AreEqual("hello world", formatter.Deserialize<string>(serializationStream));
 }
        public void TestDeserialize()
        {
            var subFormatter        = new Mock <ICauterizeTypeFormatter>();
            var serializationStream = new MemoryStream();

            subFormatter.Setup(sf => sf.Deserialize(serializationStream, typeof(string))).Returns("hello world");
            var factory = new Mock <CauterizeTypeFormatterFactory>();

            factory.Setup(f => f.GetFormatter(typeof(string))).Returns(subFormatter.Object);
            var formatter = new CauterizeFormatter(factory.Object);

            Assert.AreEqual("hello world", formatter.Deserialize <string>(serializationStream));
        }