public void TestSerializeIf() { TestGen(cl => { var src = new Sample2 { X = 1, Y = "a" }; var dst = cl.Deep(src); Assert.AreNotEqual(src, dst); Assert.AreEqual(src.X, dst.X); Assert.AreEqual(src.Y, dst.Y); }); TestGen(cl => { var src = new Sample2 { X = 1, Y = "1" }; var dst = cl.Deep(src); Assert.AreNotEqual(src, dst); Assert.AreEqual(src.X, dst.X); Assert.IsNull(dst.Y); }); TestGen(cl => { var src = new SampleSerializeIf { X = 7, Y = new Sample1 { X = 7 } }; var dst = cl.Deep(src); Assert.AreNotEqual(src, dst); Assert.AreEqual(src.X, dst.X); Assert.IsNull(dst.Y); }); TestGen(cl => { var src = new Sample1 { X = 7, Y = "ttt" }; var dst = cl.Deep(src); Assert.AreNotEqual(src, dst); Assert.AreEqual(src.X, dst.X); Assert.AreEqual("zzz", dst.Y); }); }