public void op_String_string_whenNullValue() { const string name = "name"; var document = new JsonObject { new JsonPair(name, new JsonNull()) }; Assert.Null(document.String(name)); }
public void op_ReadJson_JsonReader(string json) { using (var stream = new MemoryStream()) { using (var writer = new StreamWriter(stream)) { writer.Write(json); writer.Flush(); stream.Position = 0; using (var reader = new JsonReader(stream)) { reader.Read(); var obj = new JsonObject(); obj.ReadJson(reader); Assert.Equal("value", obj.String("name").Value); Assert.Equal("1", obj.Array("range").Number(0).Value); Assert.Equal("2", obj.Array("range").Number(1).Value); Assert.Equal("3", obj.Array("range").Number(2).Value); Assert.Equal("123", obj.Number("id").Value); Assert.True(obj.Boolean("visible")); Assert.False(obj.Boolean("enabled")); Assert.Null(obj.String("check")); Assert.Equal("1.23", obj.Object("child").Number("value").Value); } } } }
public void op_String_string() { const string name = "name"; var expected = new JsonString("value"); var document = new JsonObject { new JsonPair(name, expected) }; var actual = document.String(name); Assert.Equal(expected, actual); }
public void op_Add_string_JsonValue() { const string name = "name"; var expected = new JsonString("value"); var document = new JsonObject { { name, expected } }; var actual = document.String(name); Assert.Equal(expected, actual); }