public void ShouldPlaceSurrogateForDerivedObject() { var d = new SurrogateMockD(); var pseudocopy = PseudoClone(d, serializer => { serializer.ForObject <SurrogateMockC>().SetSurrogate(x => new SurrogateMockB()); }); var b = pseudocopy as SurrogateMockB; Assert.IsNotNull(b); }
public void ShouldTreatNullAsDontSurrogateThisType() { var d = new SurrogateMockD(); var pseudocopy = PseudoClone(d, serializer => { serializer.ForObject(typeof(SurrogateMockC)).SetSurrogate(x => "fail"); serializer.ForObject(typeof(SurrogateMockD)).SetSurrogate(null); }); Assert.IsInstanceOf <SurrogateMockD>(pseudocopy); }
public void ShouldUseMoreSpecificSurrogateIfPossible() { var mock = new SurrogateMockD(); var pseudocopy = PseudoClone(mock, serializer => { serializer.ForObject <SurrogateMockC>().SetSurrogate(x => new SurrogateMockA(1)); serializer.ForObject <SurrogateMockD>().SetSurrogate(x => new SurrogateMockB()); }); var b = pseudocopy as SurrogateMockB; Assert.IsNotNull(b); }
public void ShouldPlaceSurrogateForDerivedObject() { var d = new SurrogateMockD(); var pseudocopy = PseudoClone(d, serializer => { serializer.ForObject<SurrogateMockC>().SetSurrogate(x => new SurrogateMockB()); }); var b = pseudocopy as SurrogateMockB; Assert.IsNotNull(b); }
public void ShouldUseMoreSpecificSurrogateIfPossible() { var mock = new SurrogateMockD(); var pseudocopy = PseudoClone(mock, serializer => { serializer.ForObject<SurrogateMockC>().SetSurrogate(x => new SurrogateMockA(1)); serializer.ForObject<SurrogateMockD>().SetSurrogate(x => new SurrogateMockB()); }); var b = pseudocopy as SurrogateMockB; Assert.IsNotNull(b); }