本文整理汇总了C#中IServiceClient.Send方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceClient.Send方法的具体用法?C# IServiceClient.Send怎么用?C# IServiceClient.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IServiceClient
的用法示例。
在下文中一共展示了IServiceClient.Send方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Post_empty_request_throws_validation_exception
public void Post_empty_request_throws_validation_exception(IServiceClient client)
{
try
{
var response = client.Send<CustomersResponse>(new Customers());
Assert.Fail("Should throw Validation Exception");
}
catch (WebServiceException ex)
{
var response = (CustomersResponse)ex.ResponseDto;
var errorFields = response.ResponseStatus.Errors;
var fieldNames = errorFields.Select(x => x.FieldName).ToArray();
var fieldErrorCodes = errorFields.Select(x => x.ErrorCode).ToArray();
Assert.That(ex.StatusCode, Is.EqualTo((int)HttpStatusCode.BadRequest));
Assert.That(errorFields.Count, Is.EqualTo(ExpectedPostErrorFields.Length));
Assert.That(fieldNames, Is.EquivalentTo(ExpectedPostErrorFields));
Assert.That(fieldErrorCodes, Is.EquivalentTo(ExpectedPostErrorCodes));
}
}
示例2: Post_ValidRequest_succeeds
public void Post_ValidRequest_succeeds(IServiceClient client)
{
var response = client.Send(validRequest);
Assert.That(response.ResponseStatus, Is.Null);
}
示例3: Sync_Call_HelloWorld_with_Sync_ServiceClients_on_PreDefined_Routes
public void Sync_Call_HelloWorld_with_Sync_ServiceClients_on_PreDefined_Routes(IServiceClient client)
{
var response = client.Send<HelloResponse>(new Hello { Name = "World!" });
Assert.That(response.Result, Is.EqualTo("Hello, World!"));
}