【发布时间】:2010-01-04 15:20:44
【问题描述】:
我在服务实现中尝试了超时和抛出异常,但它并没有像我的生产代码中那样导致通道进入错误状态。
出于测试目的,我如何强制此事件发生?
下面的代码对第一个请求抛出异常,使其失败,但随后的请求成功(不幸的是,因为我的目标是让它们失败)
public class SampleService : ISampleService
{
static bool first = true;
SampleData ISampleService.SampleMethod(SampleData data)
{
if (first)
{
first = false;
throw new Exception();
}
return data;
}
}
【问题讨论】: