本文整理汇总了C#中RestClient.Posts方法的典型用法代码示例。如果您正苦于以下问题:C# RestClient.Posts方法的具体用法?C# RestClient.Posts怎么用?C# RestClient.Posts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RestClient
的用法示例。
在下文中一共展示了RestClient.Posts方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Query_PassQuery_CorrectlyAppendsQueryString
public async Task Query_PassQuery_CorrectlyAppendsQueryString()
{
dynamic client = new RestClient(BaseUri);
List<Post> posts = await client.Posts().Query(new { id = 2 }).Get();
Assert.That(posts.Count, Is.EqualTo(1));
Assert.That(posts[0].id, Is.EqualTo(2));
}
示例2: Delete_DeletePostUsingResourceMethod_HttpResponseMessageReturnsOK
public async Task Delete_DeletePostUsingResourceMethod_HttpResponseMessageReturnsOK()
{
dynamic client = new RestClient(BaseUri);
var result = await client.Posts().Resource(1).Delete();
Assert.That(result.HttpResponseMessage.StatusCode, Is.EqualTo(HttpStatusCode.OK));
}
示例3: Put_UpdatePostWithStaticType_UpdatesAndReturnsNewResourceAsStaticType
public async Task Put_UpdatePostWithStaticType_UpdatesAndReturnsNewResourceAsStaticType()
{
dynamic client = new RestClient(BaseUri);
var post = new Post { title = "foo", body = "bar", userId = 10 };
var result = await client.Posts(1).Put(post);
Assert.That(result.title, Is.EqualTo(post.title));
Assert.That(result.body, Is.EqualTo(post.body));
Assert.That(result.userId, Is.EqualTo(post.userId));
Assert.That(result.HttpResponseMessage.StatusCode, Is.EqualTo(HttpStatusCode.OK));
}
示例4: Get_NestedCommentsFromPost_GetsCommentCorrectly
public async Task Get_NestedCommentsFromPost_GetsCommentCorrectly()
{
dynamic client = new RestClient(BaseUri);
List<Post> post = await client.Posts(2).Comments.Get();
Assert.That(post.First().id, Is.EqualTo(6));
}
示例5: Get_SinglePostSynchronously_GetsPostCorrectly
public void Get_SinglePostSynchronously_GetsPostCorrectly()
{
dynamic client = new RestClient(BaseUri);
HttpResponseMessage httpResponseMessage = client.Posts(1).Get().Result;
Assert.That(httpResponseMessage.StatusCode, Is.EqualTo(HttpStatusCode.OK));
}
示例6: Get_SinglePostUsingInlineMethod_GetsPostCorrectly
public async Task Get_SinglePostUsingInlineMethod_GetsPostCorrectly()
{
dynamic client = new RestClient(BaseUri);
HttpResponseMessage httpResponseMessage = await client.Posts(1).Get();
Assert.That(httpResponseMessage.StatusCode, Is.EqualTo(HttpStatusCode.OK));
}