Пример #1
0
        public void SerializeTest()
        {
            INodeWriter serializer = new JsonNodeWriter();

            serializer.Serialize("hello", null);
            Assert.AreEqual("\"hello\" : {\n}", serializer.ToString());

            serializer = new JsonNodeWriter();
            serializer.Serialize("hello", new NodeObj("hello", "world"));
            Assert.AreEqual("\"hello\" : {\n  \"hello\" : \"world\"\n}", serializer.ToString());
            serializer.Serialize("world", new NodeObj("hello", new NodeObj("hello", "world")));
            Assert.AreEqual("\"hello\" : {\n  \"hello\" : \"world\"\n},\n\"world\" : {\n  \"hello\" : {\n    \"hello\" : \"world\"\n  }\n}", serializer.ToString());
        }
Пример #2
0
        public void ToStringTest()
        {
            INodeWriter serializer = new JsonNodeWriter();

            Assert.AreEqual(string.Empty, serializer.ToString());
            serializer.Serialize("hello", null);
            Assert.AreEqual("\"hello\" : {\n}", serializer.ToString());
        }