public void Initializer_Override_Class() { int methodCalled = 0; CloneConfig <TestClass2> .Initializer = (x) => { methodCalled++; return(new TestClass2(x.Prop)); }; var source = new TestClass2(6); var dest = source.GetClone(); Assert.NotNull(dest); Assert.NotSame(source, dest); Assert.Equal(source.Prop, dest.Prop); Assert.Equal(6, dest.Prop); Assert.Equal(1, methodCalled); }
public void NoCloneAttributeTests_TestClass2() { var source = new TestClass2(3, 4) { PropOne = 1, PropTwo = 2 }; var dest = source.GetClone(); var getterPropThree = ModelAccess <TestClass2> .GetGetter("PropThree").GetDelegate <object>(); var getterPropFour = ModelAccess <TestClass2> .GetGetter("PropFour").GetDelegate <object>(); var destPropThree = getterPropThree(ref dest); var destPropFour = getterPropFour(ref dest); Assert.Equal(1, dest.PropOne); Assert.Equal(default, dest.PropTwo);