本文整理汇总了C#中Xunit.JsonObject.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# JsonObject.ToString方法的具体用法?C# JsonObject.ToString怎么用?C# JsonObject.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xunit.JsonObject
的用法示例。
在下文中一共展示了JsonObject.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: JsonObject_ToString_OrderingMaintained
public void JsonObject_ToString_OrderingMaintained()
{
var obj = new JsonObject();
obj["a"] = 1;
obj["c"] = 3;
obj["b"] = 2;
Assert.Equal("{\"a\": 1, \"b\": 2, \"c\": 3}", obj.ToString());
}
示例2: dynamic_case
public void dynamic_case()
{
dynamic jobject = new JsonObject();
jobject.name = "test";
jobject.value = 1;
jobject.list = new object[] { 5, "test" };
string json = jobject.ToString();
json.ShouldEqual("{\"name\":\"test\",\"value\":1,\"list\":[5,\"test\"]}");
}
示例3: general_case
public void general_case()
{
var jobject = new JsonObject();
jobject["name"] = new JsonValue("test");
jobject["value"] = new JsonValue(1);
jobject["list"] = new JsonArray { new JsonValue(5), new JsonValue("test") };
var json = jobject.ToString();
json.ShouldEqual("{\"name\":\"test\",\"value\":1,\"list\":[5,\"test\"]}");
}
示例4: GetTestingEventsClient
private EventsClient GetTestingEventsClient(JsonObject response)
{
var responseString = response.ToString();
var httpClientMock = Substitute.For<IHttpClient>();
httpClientMock.Send(Arg.Is((IRequest r) => r.Endpoint.ToString().Contains("events")), Arg.Any<CancellationToken>()).Returns(Task.FromResult(
new Response(HttpStatusCode.Accepted, responseString, new Dictionary<string, string>(), "application/json") as IResponse));
return new EventsClient(new ApiConnection(new Connection(new ProductHeaderValue("mock"), httpClientMock)));
}
示例5: op_ToString
public void op_ToString(string expected)
{
var obj = new JsonObject
{
new JsonPair("list",
new JsonArray
{
Values =
{
new JsonTrue(),
new JsonArray
{
Values =
{
new JsonNumber("1"),
new JsonNumber("2"),
new JsonNumber("3")
}
},
new JsonFalse()
}
})
};
var actual = obj.ToString();
Assert.Equal(expected, actual);
}
示例6: create_json_object_with_string_type_property
public void create_json_object_with_string_type_property()
{
var jobject = new JsonObject();
jobject["test"] = new JsonValue("test");
jobject.ToString().ShouldEqual("{\"test\":\"test\"}");
}
示例7: create_json_object_with_float_type_property
public void create_json_object_with_float_type_property()
{
var jobject = new JsonObject();
jobject["test"] = new JsonValue(10F);
jobject.ToString().ShouldEqual("{\"test\":10.0}");
}
示例8: create_json_object_with_false_property
public void create_json_object_with_false_property()
{
var jobject = new JsonObject();
jobject["test"] = new JsonValue(false);
jobject.ToString().ShouldEqual("{\"test\":false}");
}
示例9: create_json_object_with_empty_array
public void create_json_object_with_empty_array()
{
var jobject = new JsonObject();
jobject["test"] = new JsonArray(new object[0]);
jobject.ToString().ShouldEqual("{\"test\":[]}");
}
示例10: ShouldParseDocumentInfo
public void ShouldParseDocumentInfo()
{
var obj = new JsonObject(@"{ ""some_prop"": ""some value"" }");
Assert.Equal(@"{""some_prop"":""some value""}", obj.ToString());
}
示例11: create_json_object_with_a_property
public void create_json_object_with_a_property()
{
var jobject = new JsonObject();
jobject["test"] = new JsonObject();
jobject.ToString().ShouldEqual("{\"test\":{}}");
}
示例12: create_json_object_with_array_with_only_one_element
public void create_json_object_with_array_with_only_one_element()
{
var jobject = new JsonObject();
jobject["test"] = new JsonArray(new object[] { 5 });
jobject.ToString().ShouldEqual("{\"test\":[5]}");
}
示例13: create_json_object_with_array_property
public void create_json_object_with_array_property()
{
var jobject = new JsonObject();
jobject["test"] = new JsonArray(new[] { 1, 2, 3 });
jobject.ToString().ShouldEqual("{\"test\":[1,2,3]}");
}
示例14: create_json_object_with_array_of_mix_types_property
public void create_json_object_with_array_of_mix_types_property()
{
var jobject = new JsonObject();
jobject["test"] = new JsonArray(new object[] { 1, "my", true });
jobject.ToString().ShouldEqual("{\"test\":[1,\"my\",true]}");
}
示例15: create_json_object
public void create_json_object()
{
var jobject = new JsonObject();
jobject.ToString().ShouldEqual("{}");
}