internal Action <TestCtorA> checkCtorCProc(TestCtorA a) { Action <TestCtorA> check = b => { Assert.Equal(a.GetType(), b.GetType()); Assert.Equal(a.A, b.A); Assert.Equal(a.B, b.B); if (a is TestCtorB cb) { TestCtorB cb2 = b as TestCtorB; Assert.Equal(cb.C, cb2.C); Assert.Equal(cb.EnumA, cb2.EnumA); if (cb.TestA == null) { Assert.Null(cb2.TestA); } else { checkTestAProc(cb.TestA)(cb2.TestA); } } if (a is TestCtorC cc) { TestCtorB p1 = cc.Parent; TestCtorB p2 = (b as TestCtorC).Parent; if (p1 == null) { Assert.Null(p2); } else { checkCtorCProc(p1).Invoke(p2); } TestCtorA t1 = cc.Temp; TestCtorA t2 = (b as TestCtorC).Temp; if (t1 == null) { Assert.Null(t2); } else { checkCtorCProc(t1).Invoke(t2); } } }; return(check); }