Hey Stef,
We are looking into using WireMock.net for UI tests for one of our products. To give it some context, we have a single page Aurelia Frontend application talking to a backend using WebAPI2.
We serve the frontend files (/index, etc) but we also have /api/xxx where our backend responds.
And /api/signalr, where the signalr connection lives.
All on the same url:port.
We created a POC to provide fake api data to the frontend using WireMock and that works.
We had to do a little bit of "trickery" to be able to still host our frontend files, by making a "StaticResourceResponseProvider" that allows us to server files from disk based on the URI.
So all uri's now go to the StaticResourceResponseProvider, except for /api/, using the regex "^(?!/api/.$).*".
Per UI test we have different Given/RespondWith setups we do based on what /api/xxx calls we expect and require.
If we had access to the Owin pipeline you use inside WireMock.net we could hook this up a bit nicer (and without fonts breaking, due to always being sent as string, instead of bytes with encoding, courtesy of the string Body property in ResponseMessage).
But why we "really" need access to the Owin pipeline is because we also want to hook up SignalR. We cannot use Response.Create().WithProxy as that breaks the SignalR connection. So ideally I would want to register that on the IAppBuilder, such as:
public void Configuration(IAppBuilder app)
{
app.UseCors(CorsOptions.AllowAll);
app.MapSignalR();
}
We were looking at ways to accomplish this in WireMock.net, but found no readily available paths. One of the (least intrusive) solutions could be if IOwinSelfHost was public and it could be injected as an argument on the Start methods in FluentMockServer. Right now the private constructor there accepts settings and depending on the pragma NETSTANDARD, either AspNetCoreSelfHost or OwinSelfHost is spawned.
I could imagine creating my own implementation of OwinSelfHost where I can setup any Owin components I would like to use.
Or maybe you have a different/better idea, I am open to suggestions.