本文整理汇总了C#中IRestClient.Get方法的典型用法代码示例。如果您正苦于以下问题:C# IRestClient.Get方法的具体用法?C# IRestClient.Get怎么用?C# IRestClient.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRestClient
的用法示例。
在下文中一共展示了IRestClient.Get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Get_empty_request_throws_validation_exception
public void Get_empty_request_throws_validation_exception(IRestClient client)
{
try
{
var response = client.Get<CustomersResponse>("/Customers");
Assert.Fail("Should throw Validation Exception");
}
catch (WebServiceException ex)
{
var response = (CustomersResponse)ex.ResponseDto;
var errorFields = response.ResponseStatus.Errors;
Assert.That(ex.StatusCode, Is.EqualTo((int)HttpStatusCode.BadRequest));
Assert.That(errorFields.Count, Is.EqualTo(1));
Assert.That(errorFields[0].ErrorCode, Is.EqualTo("NotEqual"));
Assert.That(errorFields[0].FieldName, Is.EqualTo("Id"));
}
}
示例2: Get_empty_request_throws_validation_exception
public void Get_empty_request_throws_validation_exception(IRestClient client)
{
try
{
var response = client.Get(new Customers());
response.PrintDump();
Assert.Fail("Should throw Validation Exception");
}
catch (WebServiceException ex)
{
var response = (CustomersResponse)ex.ResponseDto;
var errorFields = response.ResponseStatus.Errors;
Assert.That(ex.StatusCode, Is.EqualTo((int)HttpStatusCode.BadRequest));
//Assert.That(ex.StatusDescription, Is.EqualTo("NotEqual")); //BadRequest
Assert.That(response.ResponseStatus.Message, Is.EqualTo("'Id' should not be equal to '0'."));
Assert.That(errorFields.Count, Is.EqualTo(1));
Assert.That(errorFields[0].ErrorCode, Is.EqualTo("NotEqual"));
Assert.That(errorFields[0].FieldName, Is.EqualTo("Id"));
Assert.That(errorFields[0].Message, Is.EqualTo("'Id' should not be equal to '0'."));
}
}
示例3: Sync_Call_HelloWorld_with_RestClients_on_UserDefined_Routes
public void Sync_Call_HelloWorld_with_RestClients_on_UserDefined_Routes(IRestClient client)
{
var response = client.Get<HelloResponse>("/hello/World!");
Assert.That(response.Result, Is.EqualTo("Hello, World!"));
}