public void Test_PocosNull() { PocoSimple val = null; var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <PocoSimple>(buf); Assert.AreEqual(val, cloned); }
public void Test_PocosSimple() { var val = new PocoSimple() { Int = 1, Str = "1", }; var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <PocoSimple>(buf); Assert.AreEqual(val, cloned); }
public void Test_PocosSimpleNonGeneric() { var val = new PocoSimple() { Int = 1, Str = "1", }; var buf = BinaryConvert.SerializeObject(typeof(PocoSimple), val); var cloned = BinaryConvert.DeserializeObject(typeof(PocoSimple), buf); Assert.AreEqual(val, cloned); }
public void Test_ClassMapIgnore2() { SerializerRegistry.RegisterClassMap(typeof(PocoSimple), new ClassMap <PocoSimple>(cm => { cm.MapProperty(p => p.Str).Ignored = true; })); var val = new PocoSimple() { Int = 1, Str = "2", }; var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <PocoSimple>(buf); Assert.AreEqual(val, cloned); //Note: comparer use class map, so ite return equal even that they are not! Assert.AreEqual(cloned.Int, 1); Assert.AreEqual(cloned.Str, null); }
public void Test_ArrayOfObjects() { var val = new PocoSimple[] { new PocoSimple() { Int = 1, Str = "1" }, new PocoSimple() { Int = 2, Str = "2" }, new PocoSimple() { Int = 3, Str = "3" }, null }; var buf = BinaryConvert.SerializeObject(val); var cloned = BinaryConvert.DeserializeObject <PocoSimple[]>(buf); CollectionAssert.AreEqual(val, cloned); }