public void testDemoHashedPropertiesForUserguide() { HashedTestContainer testData = new HashedTestContainer(); testData.Name2Number = new Dictionary <string, int>(); testData.Name2Number["one"] = 1; testData.Name2Number["two"] = 2; testData.Name2Number["three"] = 3; testData.Name2Number["four"] = 4; testData.Number2Name = new Dictionary <int, string>(); testData.Number2Name[1] = "one"; testData.Number2Name[2] = "two"; testData.Number2Name[3] = "three"; testData.Number2Name[4] = "four"; Object2Json o2J = new Object2Json(); o2J.NodeExpander = new PropertyReflectionNodeExpander(); // make the format prettier o2J.IndentSize = 2; string json = o2J.toJson(testData); System.Console.WriteLine("json=" + json); string[] expressions = { "Name2Number['one']" }; object[] expectedValues = { testData.Name2Number["one"] }; validateJSON(json, expressions, expectedValues, "testDemoHashedPropertiesForUserguide"); }
public void testDemoHashedPropertiesForUserguide() { HashedTestContainer testData = new HashedTestContainer(); testData.Name2Number = new Dictionary<string, int>(); testData.Name2Number["one"] = 1; testData.Name2Number["two"] = 2; testData.Name2Number["three"] = 3; testData.Name2Number["four"] = 4; testData.Number2Name = new Dictionary<int, string>(); testData.Number2Name[1]="one"; testData.Number2Name[2]="two"; testData.Number2Name[3]="three"; testData.Number2Name[4]="four"; Object2Json o2J = new Object2Json(); o2J.NodeExpander = new PropertyReflectionNodeExpander(); // make the format prettier o2J.IndentSize = 2; string json = o2J.toJson(testData); System.Console.WriteLine("json=" + json); string[] expressions = { "Name2Number['one']"}; object[] expectedValues = { testData.Name2Number["one"]}; validateJSON(json, expressions, expectedValues, "testDemoHashedPropertiesForUserguide"); }