I was wondering if there is a recommended way to test service methods that utilise the Request and cache object.
public object Any(MyDto request){
return Request.ToOptimizedResultUsingCache(Cache, ...);
}
I have test doubles, xunit AppHostFixtures and a few other approaches but was wondering if there was a recommended or cleaner way to test cache service methods isolated from the AppHost?
I’d just be using a self-host integration test, it’s easier to setup and it tests what actually happens.
Otherwise you could potentially use the generic BasicAppHost and inject a dummy BasicRequest() into your Service then read what was written to the req.Response.OutputStream.
Yep Mocking is fine, although my preference is to test as much as I can, with the least code required so I’d always use Integration Tests for anything testing functionality in the Request Pipeline.