public void testClassCycle() { var ser = new Serializer(); var d = new SerializeTestClass(); d.x = 42; d.i = 99; d.s = "hello"; d.obj = d; var data = ser.Serialize(d); }
public void testClassCycle() { var ser = new Serializer(); var d = new SerializeTestClass(); d.x = 42; d.i = 99; d.s = "hello"; d.obj = d; Assert.Throws <ArgumentException>(() => ser.Serialize(d)); }
private IDictionary testclassConverter(object obj) { SerializeTestClass o = (SerializeTestClass)obj; IDictionary result = new Hashtable(); result["__class@__"] = o.GetType().Name + "@"; result["i@"] = o.i; result["s@"] = o.s; result["x@"] = o.x; return(result); }
public void testClassCycle() { var ser = new Serializer(); var d = new SerializeTestClass(); d.x = 42; d.i = 99; d.s = "hello"; d.obj = d; var data = ser.Serialize(d); }
public void TestClass2() { Serializer.RegisterClass(typeof(SerializeTestClass), null); Serializer serpent = new Serializer(true, namespaceInClassName: true); object obj = new SerializeTestClass { i = 99, s = "hi", x = 42 }; var ser = strip_header(serpent.Serialize(obj)); Assert.Equal("{\n '__class__': 'Razorvine.Serpent.Test.SerializeTestClass',\n 'i': 99,\n 'obj': None,\n 's': 'hi'\n}", S(ser)); }
public void TestCustomClassDict() { Serializer.RegisterClass(typeof(SerializeTestClass), testclassConverter); Serializer serpent = new Serializer(true); var obj = new SerializeTestClass { i = 99, s = "hi", x = 42 }; var ser = strip_header(serpent.Serialize(obj)); Assert.Equal("{\n '__class@__': 'SerializeTestClass@',\n 'i@': 99,\n 's@': 'hi',\n 'x@': 42\n}", S(ser)); }
public void TestClass() { Serializer.RegisterClass(typeof(SerializeTestClass), null); Serializer serpent = new Serializer(true); var obj = new SerializeTestClass { i = 99, s = "hi", x = 42 }; var ser = strip_header(serpent.Serialize(obj)); Assert.Equal("{\n '__class__': 'SerializeTestClass',\n 'i': 99,\n 'obj': None,\n 's': 'hi'\n}", S(ser)); }
public void TestClass() { Serializer.RegisterClass(typeof(SerializeTestClass), null); Serializer serpent = new Serializer(indent: true); object obj = new UnserializableClass(); Assert.Throws <SerializationException>(() => serpent.Serialize(obj)); obj = new SerializeTestClass() { i = 99, s = "hi", x = 42 }; byte[] ser = strip_header(serpent.Serialize(obj)); Assert.AreEqual("{\n '__class__': 'SerializeTestClass',\n 'i': 99,\n 'obj': None,\n 's': 'hi'\n}", S(ser)); }
public void testClassCycle() { var ser = new Serializer(); var d = new SerializeTestClass { x = 42, i = 99, s = "hello" }; d.obj = d; try { ser.Serialize(d); throw new Exception("should not reach this"); } catch (ArgumentException x) { Assert.Contains("nesting too deep", x.Message); } }
protected bool Equals(SerializeTestClass other) { return(x == other.x && string.Equals(s, other.s) && i == other.i && Equals(obj, other.obj)); }
public void TestCustomClassDict() { Serializer.RegisterClass(typeof(SerializeTestClass), testclassConverter); Serializer serpent = new Serializer(indent: true); var obj = new SerializeTestClass() { i = 99, s = "hi", x = 42 }; byte[] ser = strip_header(serpent.Serialize(obj)); Assert.AreEqual("{\n '__class@__': 'SerializeTestClass@',\n 'i@': 99,\n 's@': 'hi',\n 'x@': 42\n}", S(ser)); }
public void TestClass2() { Serializer.RegisterClass(typeof(SerializeTestClass), null); Serializer serpent = new Serializer(indent: true, namespaceInClassName: true); object obj = new SerializeTestClass() { i = 99, s = "hi", x = 42 }; byte[] ser = strip_header(serpent.Serialize(obj)); Assert.AreEqual("{\n '__class__': 'Razorvine.Serpent.Test.SerializeTestClass',\n 'i': 99,\n 'obj': None,\n 's': 'hi'\n}", S(ser)); }
public void TestClass() { Serializer.RegisterClass(typeof(SerializeTestClass), null); Serializer serpent = new Serializer(indent: true); object obj = new UnserializableClass(); Assert.Throws<SerializationException>( ()=>serpent.Serialize(obj) ); obj = new SerializeTestClass() { i = 99, s = "hi", x = 42 }; byte[] ser = strip_header(serpent.Serialize(obj)); Assert.AreEqual("{\n '__class__': 'SerializeTestClass',\n 'i': 99,\n 'obj': None,\n 's': 'hi'\n}", S(ser)); }