private static void TestClassInList() { var theClass = new ClassWithNativeObjects(); var list = new List <ClassWithNativeObjects>() { theClass, }; var serializer = new Serializer(); var res = serializer.Serialize(list); Assert("System.Collections.Generic.List`1[CsLuaTest.Serialization.ClassWithNativeObjects]", res["type"]); var subRes = res["2#_0"] as NativeLuaTable; Assert(theClass.AString, subRes["2_AString"]); Assert(theClass.ANumber, subRes["2_ANumber"]); var processedClass = serializer.Deserialize <List <ClassWithNativeObjects> >(res); Assert(1, processedClass.Count); var res1 = processedClass[0]; Assert(theClass.AString, res1.AString); var res2 = processedClass[0].AString; Assert(theClass.AString, res2); Assert(theClass.ANumber, processedClass[0].ANumber); }
private static void TestBasicSerializableClass() { var serializer = new Serializer(); var theClass = new ClassWithNativeObjects(); var res = serializer.Serialize(theClass); Assert(theClass.AString, res["2_AString"]); Assert(theClass.ANumber, res["2_ANumber"]); Assert("CsLuaTest.Serialization.ClassWithNativeObjects", res["type"]); var processedClass = serializer.Deserialize <ClassWithNativeObjects>(res); Assert(theClass.AString, processedClass.AString); Assert(theClass.ANumber, processedClass.ANumber); }