I tried timeouts and excluded exceptions from the service implementation, but this did not cause the channel to go into a faulty state, as it happens in my production code.
How can I make this event happen for testing purposes?
The following code throws an exception for the first request, which makes it unsuccessful, but subsequent requests succeed (unfortunately, since my goal is to make them fail)
public class SampleService : ISampleService
{
static bool first = true;
SampleData ISampleService.SampleMethod(SampleData data)
{
if (first)
{
first = false;
throw new Exception();
}
return data;
}
}
source
share