public void ThreeSubnodes()
        {
            ThreeSubnodesTestClass a = new ThreeSubnodesTestClass
            {
                A = 123,
                B = "testString",
                C = NanoState.Ignore
            };

            XmlDocument target = new XmlDocument();

            Serializer.Serialize((SystemXmlAdapter)target, a);

            Assert.AreEqual(3, target.DocumentElement.ChildNodes.Count);
            Assert.AreEqual("123", GetXmlValue(target, "A"));
            Assert.AreEqual("testString", GetXmlValue(target, "B_"));
            Assert.AreEqual("Ignore", GetXmlValue(target, "C"));

            ThreeSubnodesTestClass b = Deserializer.Deserialize <ThreeSubnodesTestClass>((SystemXmlAdapter)target);

            Assert.AreEqual(a.A, b.A);
            Assert.AreEqual(a.B, b.B);
            Assert.AreEqual(a.C, b.C);

            ThreeSubnodesTestClass c = new ThreeSubnodesTestClass();

            new Deserializer().FillObject(c, (SystemXmlAdapter)target);

            Assert.AreEqual(a.A, c.A);
            Assert.AreEqual(a.B, c.B);
            Assert.AreEqual(a.C, c.C);
        }
예제 #2
0
        public void ThreeSubnodes()
        {
            ThreeSubnodesTestClass a = new ThreeSubnodesTestClass
            {
                A = 123,
                B = "testString",
                C = NanoState.Ignore
            };

            JObject target = new JObject();

            Serializer.Serialize((NewtonsoftJsonAdapter)target, a);

            AssertChildren(4, target);
            AssertChild("123", "A", target);
            AssertChild("testString", "B_", target);
            AssertChild("Ignore", "C", target);

            ThreeSubnodesTestClass b = Deserializer.Deserialize <ThreeSubnodesTestClass>((NewtonsoftJsonAdapter)target);

            Assert.AreEqual(a.A, b.A);
            Assert.AreEqual(a.B, b.B);
            Assert.AreEqual(a.C, b.C);

            ThreeSubnodesTestClass c = new ThreeSubnodesTestClass();

            new Deserializer().FillObject(c, (NewtonsoftJsonAdapter)target);

            Assert.AreEqual(a.A, c.A);
            Assert.AreEqual(a.B, c.B);
            Assert.AreEqual(a.C, c.C);
        }