I’m using polly (8.0.0) to add some resilience to an api (which in this case calls a D365 service).
public class MyApi {
private readonly ResiliencePipeline pipeline;
private readonly IOrganizationService service;
public MyApi(ResiliencePipelineProvider<string> provider, IOrganizationService service) {
this.pipeline = provider.getPipeline("retry-pipeline");
this.service = service;
}
public List<string> GetSomething(QueryByAttribute query) {
var result = this.pipeline.Execute(() => service.RetrieveMultiple(query));
return result.Entities.Cast<string>.ToList();
}
}
The docs (https://www.pollydocs.org/advanced/testing.html) describe how you can inject in a ResiliencePipelineProvider into your api to access the pipeline. This can be mocked, e.g. to return a ResiliencePipeline.Empty, it describes, and the details of your pipeline configuration can be tested as well.
However – how do I test that my pipeline is actually used? ResiliencePipeline can’t be mocked with moq. (“Type to mock (ResiliencePipeline) must be an interface, a delegate, or a non-sealed, non-static class”)
4