Esempio n. 1
0
        public void ContentHandlerObsoleteTest()
        {
            var h    = new ContentHandler();
            var obj1 = h.CreateObjectFrom("<a><b>test</b><c/></a>");
            var obj2 = h.CreateObjectFromTypeInAssembly("xml", "RestTests.FewTypes", "RestTests.dll");
            var obj3 = h.CreateObjectFromTypeInAssemblyWithParams("xml", "RestTests.FewTypes", "RestTests.dll",
                                                                  new[] { "true" });
            var obj4 = h.CreateObjectFromPropertyOf("a", obj1);

            Assert.IsNotNull(obj1);
            Assert.IsNotNull(obj2);
            Assert.IsNotNull(obj3);
            Assert.IsNotNull(obj4);
        }
Esempio n. 2
0
        public void ContentHandlerObjectFromInTest()
        {
            var h       = new ContentHandler();
            var baseObj = h.ObjectFrom("<a><b>test</b></a>");
            // use the deprecated one at least once to ensure it works
            var subObj = h.CreateObjectFromPropertyOf("/a", baseObj);

            Assert.AreEqual("<b>test</b>", subObj.Serialize());
            subObj = h.ObjectFromPropertyOf("/q", baseObj);
            Assert.IsTrue(string.IsNullOrEmpty(subObj.Serialize()));
            var jsonObj    = h.ObjectFrom("{ \"a\": { \"b\":\"test\" }}");
            var subJsonObj = h.ObjectFromPropertyOf("a", jsonObj);

            Assert.AreEqual("{\"b\":\"test\"}", subJsonObj.Serialize());
        }