示例#1
0
    public ThirdLevelClass Build()
    {
        TopClass         top         = TopClass.GetInstance();
        SecondLevelClass secondLevel = top.CreateSecondLevelElement();

        return(secondLevel.CreateThirdLevelElement());
    }
示例#2
0
        public static void Test_Can_Serialize_Then_Deserialize_With_Correct_Values_Multi_Level()
        {
            //arrange
            SerializerService serializer = new SerializerService();

            Assert.DoesNotThrow(() => serializer.RegisterType(typeof(SecondLevelClass)));
            serializer.Compile();

            //act
            byte[] bytes = serializer.Serialize(new SecondLevelClass()
            {
                i = 4356, b = 75432, c = 88585, TestString = "This is a test string.!"
            });
            SecondLevelClass child = serializer.Deserialize <TestBaseClass>(bytes) as SecondLevelClass;

            //assert
            Assert.NotNull(child);

            Assert.AreEqual("This is a test string.!", child.TestString);
            Assert.AreEqual(88585, child.c);
            Assert.AreEqual(75432, child.b);
            Assert.AreEqual(4356, child.i);
        }