public void testAbstractBaseClassHierarchyPickler() { ConcreteSubClass c = new ConcreteSubClass(); Serializer serpent = new Serializer(); serpent.Serialize(c); Serializer.RegisterClass(typeof(AbstractBaseClass), AnyClassSerializer); byte[] data = serpent.Serialize(c); Assert.AreEqual("{'(SUB)CLASS':'ConcreteSubClass'}", S(strip_header(data))); }
public void testAbstractBaseClassHierarchyPickler() { ConcreteSubClass c = new ConcreteSubClass(); Pickler p = new Pickler(false); try { p.dumps(c); Assert.Fail("should crash"); } catch (PickleException x) { Assert.IsTrue(x.Message.Contains("couldn't pickle object of type")); } Pickler.registerCustomPickler(typeof(AbstractBaseClass), new AnyClassPickler()); byte[] data = p.dumps(c); Assert.IsTrue(S(data).Contains("[class=Pyrolite.Tests.Pickle.PicklerTests+ConcreteSubClass]")); }