public void TestAncestralNullableFieldsSerialization() { NullableTestPatternBuffer pb = new NullableTestPatternBuffer(4096); ThingContainer3 tc3 = new ThingContainer3(); tc3.Thing1 = new Thing(1); tc3.Thing2 = new Thing(2); tc3.Thing3 = new Thing(3); byte[] bytes1 = pb.Energize(tc3); Assert.AreEqual(1 + 1 + 4 * 3, bytes1.Length); ThingContainer3 tc3_a = pb.Energize <ThingContainer3>(bytes1); Assert.IsNotNull(tc3_a); Assert.IsNotNull(tc3_a.Thing1); Assert.IsNotNull(tc3_a.Thing2); Assert.IsNotNull(tc3_a.Thing3); Assert.AreEqual(1, tc3_a.Thing1.Value); Assert.AreEqual(2, tc3_a.Thing2.Value); Assert.AreEqual(3, tc3_a.Thing3.Value); tc3.Thing1 = null; tc3.Thing2 = null; tc3.Thing3 = null; byte[] bytes2 = pb.Energize(tc3); Assert.AreEqual(1 + 1, bytes2.Length); ThingContainer3 tc3_b = pb.Energize <ThingContainer3>(bytes2); Assert.IsNotNull(tc3_b); Assert.IsNull(tc3_b.Thing1); Assert.IsNull(tc3_b.Thing2); Assert.IsNull(tc3_b.Thing3); }
public void TestAncestralNullableFields() { NullableTestPatternBuffer pb = new NullableTestPatternBuffer(4096); ThingContainer3 tc3 = new ThingContainer3(); tc3.Thing1 = new Thing(1); tc3.Thing2 = new Thing(2); tc3.Thing3 = new Thing(3); byte[] bytes1 = pb.Energize(tc3); Assert.AreEqual(1 + 1 + 4 * 3, bytes1.Length); tc3.Thing1 = null; tc3.Thing2 = null; tc3.Thing3 = null; byte[] bytes2 = pb.Energize(tc3); Assert.AreEqual(1 + 1, bytes2.Length); }