public void TestInherit() { var ser = new Regulus.Serialization.Dynamic.Serializer(); var test = new TestGrandson(); test.Data = 100; var testChild = test as TestChild; testChild.Data = 1; var testParent = test as TestParent; testParent.Data = 33; var buf = ser.ObjectToBuffer(test); var val = (TestGrandson)ser.BufferToObject(buf); var valParent = val as TestParent; var child = val as TestChild; Assert.AreEqual(100, val.Data); Assert.AreEqual(1, child.Data); Assert.AreEqual(33, valParent.Data); }
public void TestSerializerNull() { var ser = new Regulus.Serialization.Dynamic.Serializer(); var buf = ser.ObjectToBuffer(null); var val = ser.BufferToObject(buf); Assert.AreEqual(null, val); }
public void TestSerializerString() { var ser = new Regulus.Serialization.Dynamic.Serializer(); var buf = ser.ObjectToBuffer("12345"); var val = (string)ser.BufferToObject(buf); Assert.AreEqual("12345", val); }
public void TestSerializerInt() { var ser = new Regulus.Serialization.Dynamic.Serializer(); var buf = ser.ObjectToBuffer(12345); var val = (int)ser.BufferToObject(buf); Assert.AreEqual(12345, val); }
public void TestSerializerStringArray() { var ser = new Regulus.Serialization.Dynamic.Serializer(); var buf = ser.ObjectToBuffer(new[] { "1", "2", "3", "4", "5" }); var val = (string[])ser.BufferToObject(buf); Assert.AreEqual("1", val[0]); Assert.AreEqual("2", val[1]); Assert.AreEqual("3", val[2]); Assert.AreEqual("4", val[3]); Assert.AreEqual("5", val[4]); }
public void TestSerializerArray() { var ser = new Regulus.Serialization.Dynamic.Serializer(); var buf = ser.ObjectToBuffer(new[] { 1, 2, 3, 4, 5 }); var val = (int[])ser.BufferToObject(buf); Assert.AreEqual(1, val[0]); Assert.AreEqual(2, val[1]); Assert.AreEqual(3, val[2]); Assert.AreEqual(4, val[3]); Assert.AreEqual(5, val[4]); }
public void TestClassPolytype1() { var g = new TestGrandson(); g.Data = 100; var test = new TestPoly(); test.Parent = g; var serializer = new Regulus.Serialization.Dynamic.Serializer(new CustomFinder((name) => Type.GetType(name))); var buf = serializer.ObjectToBuffer(test); var val = (TestPoly)serializer.BufferToObject(buf); var valChild = val.Parent as TestGrandson; Assert.AreEqual(100, valChild.Data); }
public void TestArray1() { var test = new TestGrandson(); test.Data = 100; var testChild = test as TestChild; testChild.Data = 1; var testParent = test as TestParent; testParent.Data = 33; var serializer = new Regulus.Serialization.Dynamic.Serializer(new CustomFinder((name) => Type.GetType(name))); var buf = serializer.ObjectToBuffer(new TestParent[] { test, testChild, testParent }); var val = (TestParent[])serializer.BufferToObject(buf); Assert.AreEqual(100, (val[0] as TestGrandson).Data); Assert.AreEqual(1, (val[1] as TestChild).Data); Assert.AreEqual(33, (val[2] as TestParent).Data); }