本文整理汇总了C#中Xunit.JsonObject.Array方法的典型用法代码示例。如果您正苦于以下问题:C# JsonObject.Array方法的具体用法?C# JsonObject.Array怎么用?C# JsonObject.Array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xunit.JsonObject
的用法示例。
在下文中一共展示了JsonObject.Array方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: op_ReadJson_JsonReader_whenNestedArrayBug
public void op_ReadJson_JsonReader_whenNestedArrayBug(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("123", obj.Array("list").Object(0).Number("count").Value);
Assert.True(obj.Array("list").Boolean(1));
}
}
}
}
示例2: op_ReadJson_JsonReader_whenNestedArray
public void op_ReadJson_JsonReader_whenNestedArray(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.True(obj.Array("list").Boolean(0));
Assert.Equal("1", obj.Array("list").Array(1).Number(0).Value);
Assert.Equal("2", obj.Array("list").Array(1).Number(1).Value);
Assert.Equal("3", obj.Array("list").Array(1).Number(2).Value);
Assert.False(obj.Array("list").Boolean(2));
Assert.True(obj.Array("list").IsNull(3));
Assert.Equal("abc", obj.Array("list").String(4).Value);
Assert.Equal("123", obj.Array("list").Object(5).Number("count").Value);
Assert.Equal("456", obj.Array("list").Object(6).Number("count").Value);
Assert.True(obj.Array("list").Boolean(7));
Assert.Equal("789", obj.Array("list").Object(8).Number("count").Value);
}
}
}
}
示例3: op_Array_string_whenNullValue
public void op_Array_string_whenNullValue()
{
const string name = "name";
var document = new JsonObject
{
new JsonPair(name, new JsonNull())
};
Assert.Null(document.Array(name));
}
示例4: op_ReadJson_JsonReader
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);
}
}
}
}
示例5: op_Array_string
public void op_Array_string()
{
const string name = "name";
var expected = new JsonArray();
var document = new JsonObject
{
new JsonPair(name, expected)
};
var actual = document.Array(name);
Assert.Equal(expected, actual);
}