public void CreateAndDisposeStructural1() { var source = new WithTwoComplexProperties("a", 1) { ComplexValue1 = new ComplexType("a.1", 2), ComplexValue2 = new ComplexType("a.2", 3) }; var target = new WithTwoComplexProperties("b", 3) { ComplexValue1 = new ComplexType("b.1", 4) }; using (Synchronize.PropertyValues(source, target, ReferenceHandling.Structural)) { Assert.AreEqual("a", source.Name); Assert.AreEqual("a", target.Name); Assert.AreEqual(1, source.Value); Assert.AreEqual(1, target.Value); Assert.AreNotSame(source.ComplexValue1, target.ComplexValue1); Assert.AreEqual("a", source.Name); Assert.AreEqual("a", target.Name); Assert.AreEqual("a.1", source.ComplexValue1.Name); Assert.AreEqual("a.1", target.ComplexValue1.Name); Assert.AreEqual("a.2", source.ComplexValue2.Name); Assert.AreEqual("a.2", target.ComplexValue2.Name); source.Value++; Assert.AreEqual("a", source.Name); Assert.AreEqual("a", target.Name); Assert.AreEqual(2, source.Value); Assert.AreEqual(2, target.Value); Assert.AreNotSame(source.ComplexValue1, target.ComplexValue1); Assert.AreEqual("a", source.Name); Assert.AreEqual("a", target.Name); Assert.AreEqual("a.1", source.ComplexValue1.Name); Assert.AreEqual("a.1", target.ComplexValue1.Name); Assert.AreEqual("a.2", source.ComplexValue2.Name); Assert.AreEqual("a.2", target.ComplexValue2.Name); source.ComplexValue1.Name += "_"; Assert.AreEqual("a", source.Name); Assert.AreEqual("a", target.Name); Assert.AreEqual("a.1_", source.ComplexValue1.Name); Assert.AreEqual("a.1_", target.ComplexValue1.Name); Assert.AreEqual("a.2", source.ComplexValue2.Name); Assert.AreEqual("a.2", target.ComplexValue2.Name); source.ComplexValue1 = source.ComplexValue2; Assert.AreEqual("a", source.Name); Assert.AreEqual("a", target.Name); Assert.AreEqual("a.2", source.ComplexValue1.Name); Assert.AreEqual("a.2", target.ComplexValue1.Name); Assert.AreEqual("a.2", source.ComplexValue2.Name); Assert.AreEqual("a.2", target.ComplexValue2.Name); source.ComplexValue2 = null; Assert.AreEqual("a", source.Name); Assert.AreEqual("a", target.Name); Assert.AreEqual("a.2", source.ComplexValue1.Name); Assert.AreEqual("a.2", target.ComplexValue1.Name); Assert.AreEqual(null, source.ComplexValue2); Assert.AreEqual(null, target.ComplexValue2); } source.Name += "_"; Assert.AreEqual("a_", source.Name); Assert.AreEqual("a", target.Name); Assert.AreEqual(2, source.Value); Assert.AreEqual(2, target.Value); Assert.AreEqual("a.2", source.ComplexValue1.Name); Assert.AreEqual("a.2", target.ComplexValue1.Name); Assert.AreEqual(null, source.ComplexValue2); Assert.AreEqual(null, target.ComplexValue2); }