コード例 #1
0
        public void testIndexedWithNull()
        {
            IndexedTestContainer testData = new IndexedTestContainer();

            testData.strings = new string[] { null, "ddd", "ccc", null };
            Object2Json o2J = new Object2Json();

            o2J.NodeExpander = new FieldReflectionNodeExpander();
            // make the format prettier
            o2J.IndentSize = 2;
            string json = o2J.toJson(testData);

            System.Console.WriteLine("json=" + json);
            string[] expressions    = { "strings[0]", "strings[1]", "strings[2]", "strings[3]" };
            object[] expectedValues = { testData.strings[0], testData.strings[1], testData.strings[2], testData.strings[3] };
            validateJSON(json, expressions, expectedValues, "testIndexedWithNull");
        }
コード例 #2
0
        public void testDemoIndexedPropertiesForUserguide()
        {
            IndexedTestContainer testData = new IndexedTestContainer();

            testData.strings = new string[] { "eee", "ddd", "ccc", "bbb" };
            testData.ints    = new List <int>(new int[] { 6, 5, 4, 3, 2, 1 });
            Object2Json o2J = new Object2Json();

            o2J.NodeExpander = new FieldReflectionNodeExpander();
            // make the format prettier
            o2J.IndentSize = 2;
            string json = o2J.toJson(testData);

            System.Console.WriteLine("json=" + json);
            string[] expressions    = { "strings[3]", "strings[0]", "ints[0]", "ints[5]" };
            object[] expectedValues = { testData.strings[3], testData.strings[0], testData.ints[0], testData.ints[5] };
            validateJSON(json, expressions, expectedValues, "testDemoIndexedPropertiesForUserguide");
        }
コード例 #3
0
 public void testIndexedWithNull()
 {
     IndexedTestContainer testData = new IndexedTestContainer();
     testData.strings = new string[] { null, "ddd", "ccc", null };
     Object2Json o2J = new Object2Json();
     o2J.NodeExpander = new FieldReflectionNodeExpander();
     // make the format prettier
     o2J.IndentSize = 2;
     string json = o2J.toJson(testData);
     System.Console.WriteLine("json=" + json);
     string[] expressions = { "strings[0]", "strings[1]", "strings[2]", "strings[3]" };
     object[] expectedValues = { testData.strings[0], testData.strings[1], testData.strings[2], testData.strings[3] };
     validateJSON(json, expressions, expectedValues, "testIndexedWithNull");
 }
コード例 #4
0
 public void testDemoIndexedPropertiesForUserguide()
 {
     IndexedTestContainer testData = new IndexedTestContainer();
     testData.strings = new string[] { "eee", "ddd", "ccc", "bbb" };
     testData.ints = new List<int>(new int[] {6,5,4,3,2,1} );
     Object2Json o2J = new Object2Json();
     o2J.NodeExpander = new FieldReflectionNodeExpander();
     // make the format prettier
     o2J.IndentSize = 2;
     string json = o2J.toJson(testData);
     System.Console.WriteLine("json=" + json);
     string[] expressions = { "strings[3]", "strings[0]", "ints[0]", "ints[5]"};
     object[] expectedValues = {testData.strings[3], testData.strings[0], testData.ints[0], testData.ints[5] };
     validateJSON(json, expressions, expectedValues, "testDemoIndexedPropertiesForUserguide");
 }