internal Action <ObjTestA> checkTestAProc(ObjTestA a) { return((b) => { Assert.Equal(a.GetType(), b.GetType()); Assert.Equal(a.A, b.A); Assert.Equal(a.B, b.B); if (a is ObjTestB ab) { ObjTestB bb = b as ObjTestB; Assert.Equal(ab.E, bb.E); if (ab.D == null) { Assert.Null(bb.D); } else { checkTestAProc(ab.D)(bb.D); } if (ab.C == null) { Assert.Null(bb.C); } else { checkTestAProc(ab.C)(bb.C); } } }); }
public void Test_Diff_Simple_Inherit() { ObjTestA a = new ObjTestA() { A = 1, B = "B" }; byte[] data = BinarySerializer.Serialize(a); var b = BinarySerializer.Deserialize <DiffObjTestB>(data); Assert.Equal((uint)1, b.A); Assert.Equal("B", b.B); }
public async Task Test_SimpleObj() { ObjTestA a = new ObjTestA() { A = 1, B = null }; await Test <ObjTestA>(null, (obj) => Assert.Null(obj)); void check(ObjTestA b) { Assert.Equal(a.A, b.A); Assert.Equal(a.B, b.B); } await Test(a, check); a.B = "AAAA"; a.A = uint.MaxValue; await Test(a, check); }
public async Task Test_SimpleObjAndBufferLength(int len) { Type type = typeof(ObjTestA); ObjTestA a = new ObjTestA() { A = 1, B = new string('A', len) }; BinarySerializerOptions options = new BinarySerializerOptions() { DefaultBufferSize = 1 }; void check(ObjTestA b) { Assert.Equal(a.A, b.A); Assert.Equal(a.B, b.B); } await Test(a, check, options); }