public void ShouldSwapWithNonGenericSurrogate() { var f = new SurrogateMockF <string>("test"); var pseudocopy = PseudoClone(f, serializer => { serializer.ForObject(typeof(SurrogateMockF <>)).SetSurrogate(x => "general"); serializer.ForObject <SurrogateMockF <string> >().SetSurrogate(x => "special"); }); Assert.AreEqual("special", pseudocopy); }
public void ShouldSwapGenericSurrogateWithObject() { var f = new SurrogateMockF <string>("test"); var pseudocopy = PseudoClone(f, serializer => serializer.ForObject(typeof(SurrogateMockF <>)).SetSurrogate(x => { var type = x.GetType(); return(type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance)[0].GetValue(x)); })); Assert.IsInstanceOf <string>(pseudocopy); }