本文整理汇总了C#中TestService.ProcessRequest方法的典型用法代码示例。如果您正苦于以下问题:C# TestService.ProcessRequest方法的具体用法?C# TestService.ProcessRequest怎么用?C# TestService.ProcessRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestService
的用法示例。
在下文中一共展示了TestService.ProcessRequest方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessRequestCalledTwiceWithSameHostShouldWork
public void ProcessRequestCalledTwiceWithSameHostShouldWork()
{
var host = new DataServiceHostSimulator {AbsoluteRequestUri = new Uri("http://example.com/Customers(1)"), AbsoluteServiceUri = new Uri("http://example.com/"), RequestHttpMethod = "GET", ResponseStream = new MemoryStream(), ProcessExceptionCallBack = (args) => { }};
var svc = new TestService();
svc.AttachHost(host);
svc.ProcessRequest();
host.ResponseStatusCode.Should().Be(200);
host.ResponseStream.Position = 0;
var customerResponse = new StreamReader(host.ResponseStream).ReadToEnd();
customerResponse.Should().Contain("Customer");
customerResponse.Should().Contain("Redmond Way");
customerResponse.Should().Contain("[email protected]");
host.ResponseStream = new MemoryStream();
host.AbsoluteRequestUri = new Uri("http://example.com/Customers(1)/Address");
// re-attach the host before calling ProcessRequest
svc.AttachHost(host);
svc.ProcessRequest();
host.ResponseStatusCode.Should().Be(200);
host.ResponseStream.Position = 0;
var addressResponse = new StreamReader(host.ResponseStream).ReadToEnd();
addressResponse.Should().Contain("Redmond Way");
addressResponse.Should().NotContain("[email protected]");
addressResponse.Should().NotMatch(customerResponse);
}
示例2: ProcessRequestCalledSecondTimeWithoutAttachHostShouldThrow
public void ProcessRequestCalledSecondTimeWithoutAttachHostShouldThrow()
{
var host = new DataServiceHostSimulator {AbsoluteRequestUri = new Uri("http://example.com/Customers(1)"), AbsoluteServiceUri = new Uri("http://example.com/"), RequestHttpMethod = "GET", ResponseStream = new MemoryStream(), ProcessExceptionCallBack = (args) => { }};
var svc = new TestService();
svc.AttachHost(host);
svc.ProcessRequest();
host.ResponseStatusCode.Should().Be(200);
host.ResponseStream.Position = 0;
var customerResponse = new StreamReader(host.ResponseStream).ReadToEnd();
customerResponse.Should().Contain("Customer");
customerResponse.Should().Contain("Redmond Way");
customerResponse.Should().Contain("[email protected]");
host.ResponseStream = new MemoryStream();
host.AbsoluteRequestUri = new Uri("http://example.com/Customers(1)/Address");
Action secondRequest = () => svc.ProcessRequest();
secondRequest.ShouldThrow<InvalidOperationException>();
}
示例3: ResponseStatusCodeIsNotSetOnHostAfterProcessRequestWith404Error
public void ResponseStatusCodeIsNotSetOnHostAfterProcessRequestWith404Error()
{
HandleExceptionArgs exceptionArgs = null;
var host = new DataServiceHostSimulator { AbsoluteRequestUri = new Uri("http://example.com/invalid"), AbsoluteServiceUri = new Uri("http://example.com/"), RequestHttpMethod = "GET", ResponseStream = new MemoryStream(), ProcessExceptionCallBack = (args) => { exceptionArgs = args; } };
var svc = new TestService();
svc.AttachHost(host);
svc.ProcessRequest();
//// Astoria Server fails to set IDSH.ResponseStatusCode for custom hosts in an error scenario
//// The behavior has been this way from V2 of WCF Data Services and on, when this is changed
//// it will be a breaking change
host.ResponseStatusCode.Should().Be(0);
host.ResponseStream.Position = 0;
var customerResponse = new StreamReader(host.ResponseStream).ReadToEnd();
customerResponse.Should().Contain("Resource not found for the segment 'invalid'.");
exceptionArgs.ResponseStatusCode.Should().Be(404);
}