public void should_set_field_number_value() { var node = new JsonNode(NodeType.Object, new Options()) { NodeType = NodeType.Object }; node.Add("field1", NodeType.Value, Metadata.Empty, x => x.Value = (decimal)1.1); node.Add("field2", NodeType.Value, Metadata.Empty, x => x.Value = (float)2.2); node.Add("field3", NodeType.Value, Metadata.Empty, x => x.Value = (double)3.3); node.Add("field4", NodeType.Value, Metadata.Empty, x => x.Value = (sbyte)4); node.Add("field5", NodeType.Value, Metadata.Empty, x => x.Value = (byte)5); node.Add("field6", NodeType.Value, Metadata.Empty, x => x.Value = (short)6); node.Add("field7", NodeType.Value, Metadata.Empty, x => x.Value = (ushort)7); node.Add("field8", NodeType.Value, Metadata.Empty, x => x.Value = (int)8); node.Add("field9", NodeType.Value, Metadata.Empty, x => x.Value = (uint)9); node.Add("field10", NodeType.Value, Metadata.Empty, x => x.Value = (long)10); node.Add("field11", NodeType.Value, Metadata.Empty, x => x.Value = (ulong)11); node.Encode().ShouldEqual("{" + "\"field1\":1.1," + "\"field2\":2.2," + "\"field3\":3.3," + "\"field4\":4," + "\"field5\":5," + "\"field6\":6," + "\"field7\":7," + "\"field8\":8," + "\"field9\":9," + "\"field10\":10," + "\"field11\":11" + "}"); }
public void should_set_field_name() { var node = new JsonNode(NodeType.Object, new Options()) { { "field2", NodeType.Value, Metadata.Empty, x => x.Value = "" } }; node.Encode().ShouldEqual("{\"field2\":\"\"}"); }
public void should_add_named_fields_to_arrays() { var node = new JsonNode(NodeType.Array, new Options()); node.NodeType.ShouldEqual(NodeType.Array); node.Add("item1", NodeType.Value, Metadata.Empty, x => x.Value = "oh"); node.Add("item2", NodeType.Value, Metadata.Empty, x => x.Value = "hai"); node.Encode().ShouldEqual("[\"oh\",\"hai\"]"); }
public void should_add_named_fields_to_objects() { var node = new JsonNode(NodeType.Object, new Options()); node.NodeType.ShouldEqual(NodeType.Object); node.Add("field1", NodeType.Value, Metadata.Empty, x => x.Value = "oh"); node.Add("field2", NodeType.Value, Metadata.Empty, x => x.Value = "hai"); node.Encode().ShouldEqual("{\"field1\":\"oh\",\"field2\":\"hai\"}"); }
public void should_set_array_bool_value() { var node = new JsonNode(NodeType.Array, new Options()) { { NodeType.Value, Metadata.Empty, x => x.Value = true } }; node.Encode().ShouldEqual("[true]"); }
public void should_save_with_whitespace() { var node = new JsonNode(NodeType.Object, Options.Create(x => x.Serialization(y => y.PrettyPrint()))) { { "field1", NodeType.Value, Metadata.Empty, x => x.Value = "hai" } }; node.Encode(UTF8Encoding.NoBOM).ShouldEqual("{\r\n \"field1\": \"hai\"\r\n}"); }
public void should_set_array_object_value() { var node = new JsonNode(NodeType.Array, new Options()) { NodeType = NodeType.Array }; node.Add(NodeType.Object, Metadata.Empty, x => {}); node.Encode().ShouldEqual("[{}]"); }
public void should_set_field_object_value() { var node = new JsonNode(NodeType.Object, new Options()) { NodeType = NodeType.Object }; node.Add("field1", NodeType.Object, Metadata.Empty, x => {}); node.Encode().ShouldEqual("{\"field1\":{}}"); }
public void should_set_field_null_value() { var node = new JsonNode(NodeType.Object, new Options()) { NodeType = NodeType.Object }; node.Add("field1", NodeType.Value, Metadata.Empty, x => x.Value = null); node.Encode().ShouldEqual("{\"field1\":null}"); }
public void should_set_array_string_value() { var node = new JsonNode(NodeType.Array, new Options()) { NodeType = NodeType.Array }; node.Add(NodeType.Value, Metadata.Empty, x => x.Value = "hai"); node.Add(NodeType.Value, Metadata.Empty, x => x.Value = 'y'); node.Encode().ShouldEqual("[\"hai\",\"y\"]"); }
public void should_set_field_string_value() { var node = new JsonNode(NodeType.Object, new Options()) { NodeType = NodeType.Object }; node.Add("field1", NodeType.Value, Metadata.Empty, x => x.Value = "hai"); node.Add("field2", NodeType.Value, Metadata.Empty, x => x.Value = 'y'); node.Encode().ShouldEqual("{\"field1\":\"hai\",\"field2\":\"y\"}"); }
public void should_set_array_number_value() { var node = new JsonNode(NodeType.Array, new Options()) { NodeType = NodeType.Array }; node.Add(NodeType.Value, Metadata.Empty, x => x.Value = (decimal)1.1); node.Add(NodeType.Value, Metadata.Empty, x => x.Value = (float)2.2); node.Add(NodeType.Value, Metadata.Empty, x => x.Value = (double)3.3); node.Add(NodeType.Value, Metadata.Empty, x => x.Value = (sbyte)4); node.Add(NodeType.Value, Metadata.Empty, x => x.Value = (byte)5); node.Add(NodeType.Value, Metadata.Empty, x => x.Value = (short)6); node.Add(NodeType.Value, Metadata.Empty, x => x.Value = (ushort)7); node.Add(NodeType.Value, Metadata.Empty, x => x.Value = (int)8); node.Add(NodeType.Value, Metadata.Empty, x => x.Value = (uint)9); node.Add(NodeType.Value, Metadata.Empty, x => x.Value = (long)10); node.Add(NodeType.Value, Metadata.Empty, x => x.Value = (ulong)11); node.Encode().ShouldEqual("[1.1,2.2,3.3,4,5,6,7,8,9,10,11]"); }