public void DumpShape_DepthTwo() { var objectDumper = new ObjectDumper(2); var testShape = new TestShape { Metadata = new ShapeMetadata() { Type = "TestContentType", DisplayType = "Detail", Alternates = new[] { "TestContentType_Detail", "TestContentType_Detail_2" }, Position = "1", ChildContent = new HtmlString("<p>Test Para</p>"), Wrappers = new[] { "TestContentType_Wrapper" } }, SomeInteger = 1337, SomeBoolean = true, SomeString = "Never gonna give you up" }; testShape.Classes.Add("bodyClass1"); testShape.Classes.Add("bodyClass2"); testShape.Add("Child Item"); testShape.Attributes.Add(new KeyValuePair<string, string>("onClick", "dhtmlIsBad")); var xElement = objectDumper.Dump(testShape, "Model"); var stringBuilder = new StringBuilder(); ObjectDumper.ConvertToJSon(xElement, stringBuilder); var json = stringBuilder.ToString(); var jObject = new JObject( new JProperty("name", "Model"), new JProperty("value", "TestContentType Shape")); ComparareJsonObject(jObject, json); }
public void DumpShapeAndChild_DepthSix() { var objectDumper = new ObjectDumper(6); var testShape = new TestShape { Metadata = new ShapeMetadata { Type = "TestContentType", DisplayType = "Detail", Alternates = new[] { "TestContentType_Detail", "TestContentType_Detail_2" }, Position = "1", ChildContent = new HtmlString("<p>Test Para</p>"), Wrappers = new[] { "TestContentType_Wrapper" } }, SomeInteger = 1337, SomeBoolean = true, SomeString = "Never gonna give you up" }; testShape.Classes.Add("bodyClass1"); testShape.Classes.Add("bodyClass2"); testShape.Add(new TestShape { Metadata = new ShapeMetadata { Type = "TestContentChildType", DisplayType = "Detail", Alternates = new[] { "TestContentChildType_Detail", "TestContentChildType_Detail_2" }, Position = "1", ChildContent = new HtmlString("<p>Test Child Para</p>"), Wrappers = new[] { "TestContentChildType_Wrapper" } }, SomeInteger = 1337, SomeBoolean = true, SomeString = "Never gonna give you up" }); testShape.Attributes.Add(new KeyValuePair<string, string>("onClick", "dhtmlIsBad")); var xElement = objectDumper.Dump(testShape, "Model"); var stringBuilder = new StringBuilder(); ObjectDumper.ConvertToJSon(xElement, stringBuilder); var json = stringBuilder.ToString(); var jObject = new JObject( new JProperty("name", "Model"), new JProperty("value", "TestContentType Shape"), new JProperty("children", new JArray( new JObject( new JProperty("name", "Classes"), new JProperty("value", "List<String>"), new JProperty("children", new JArray( new JObject( new JProperty("name", "[0]"), new JProperty("value", ""bodyClass1"")), new JObject( new JProperty("name", "[1]"), new JProperty("value", ""bodyClass2""))))), new JObject( new JProperty("name", "Attributes"), new JProperty("value", "Dictionary<String, String>"), new JProperty("children", new JArray( new JObject( new JProperty("name", "["onClick"]"), new JProperty("value", ""dhtmlIsBad""))))), new JObject( new JProperty("name", "Items"), new JProperty("value", "List<Object>"), new JProperty("children", new JArray( new JObject( new JProperty("name", "[0]"), new JProperty("value", "TestContentChildType Shape"), new JProperty("children", new JArray( new JObject( new JProperty("name", "Classes"), new JProperty("value", "List<String>")), new JObject( new JProperty("name", "Attributes"), new JProperty("value", "Dictionary<String, String>")), new JObject( new JProperty("name", "Items"), new JProperty("value", "List<Object>"))))))))))); ComparareJsonObject(jObject, json); }
public void DumpShape_DepthOne() { var objectDumper = new ObjectDumper(1); var testShape = new TestShape { Metadata = new ShapeMetadata() { Type = "TestContentType", DisplayType = "Detail", Alternates = new[] { "TestContentType_Detail", "TestContentType_Detail_2" }, Position = "1", ChildContent = new HtmlString("<p>Test Para</p>"), Wrappers = new[] { "TestContentType_Wrapper" } }, SomeInteger = 1337, SomeBoolean = true, SomeString = "Never gonna give you up" }; testShape.Classes.Add("bodyClass1"); testShape.Classes.Add("bodyClass2"); testShape.Add("Child Item"); testShape.Attributes.Add(new KeyValuePair<string, string>("onClick", "dhtmlIsBad")); var xElement = objectDumper.Dump(testShape, "Model"); Assert.Throws(typeof(NullReferenceException), () => { var stringBuilder = new StringBuilder(); ObjectDumper.ConvertToJSon(xElement, stringBuilder); var json = stringBuilder.ToString(); }); }