Ejemplo n.º 1
0
        public void TestInterfaceHierarchyPickler()
        {
            BaseClassWithInterface b   = new BaseClassWithInterface();
            SubClassWithInterface  sub = new SubClassWithInterface();
            Pickler p = new Pickler(false);

            try {
                p.dumps(b);
                Assert.True(false, "should crash");
            } catch (PickleException x)
            {
                Assert.Contains("couldn't pickle object of type", x.Message);
            }
            try {
                p.dumps(sub);
                Assert.True(false, "should crash");
            } catch (PickleException x) {
                Assert.Contains("couldn't pickle object of type", x.Message);
            }
            Pickler.registerCustomPickler(typeof(IBaseInterface), new AnyClassPickler());
            byte[] data = p.dumps(b);
            Assert.Contains("[class=PickleTests.PicklerTests+BaseClassWithInterface]", S(data));
            data = p.dumps(sub);
            Assert.Contains("[class=PickleTests.PicklerTests+SubClassWithInterface]", S(data));
        }
Ejemplo n.º 2
0
        public void TestInterfaceHierarchyPickler()
        {
            BaseClassWithInterface b       = new BaseClassWithInterface();
            SubClassWithInterface  sub     = new SubClassWithInterface();
            Serializer             serpent = new Serializer();

            serpent.Serialize(b);
            serpent.Serialize(sub);
            Serializer.RegisterClass(typeof(IBaseInterface), AnyClassSerializer);
            byte[] data = serpent.Serialize(b);
            Assert.AreEqual("{'(SUB)CLASS':'BaseClassWithInterface'}", S(strip_header(data)));
            data = serpent.Serialize(sub);
            Assert.AreEqual("{'(SUB)CLASS':'SubClassWithInterface'}", S(strip_header(data)));
        }
Ejemplo n.º 3
0
        public void BaseClassWithInterface_VirtualMethod_Invoking()
        {
            IBaseClassWithInterface bc = new BaseClassWithInterface();

            bc.NonVirtualMethod();
        }