예제 #1
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
 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);
 }
예제 #5
0
 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);
 }