I have an n-tier MVC app with an MVC5 frontend, and a WebAPI2 backend.
I am normally calling between the two using RestSharp
For testing/development purposes (primarily to be able to use glimpse or other profiling tools end-to-end) I want to be able to easily flip a switch to use the application in a single tier mode.
I could manually make calls to the appropriate WebAPI controller classes and methods, but that would be a lot of duplication of logic.
Since I already have URLs built up with all of the parameters correctly set, is there a way to call the controller (or some factory that can pick between controllers) and say "Hey, pretend this just came in over the wire and process it for me"
-
OWIN self host is what I use for my Web API unit testing.tia– tia2015年05月29日 15:51:39 +00:00Commented May 29, 2015 at 15:51
-
that would still send things out of process over http wouldn't it?Jason Coyne– Jason Coyne2015年05月29日 16:05:43 +00:00Commented May 29, 2015 at 16:05
-
Based on how URL routing works in WebAPI, I don't believe this is either too feasible or too advisable. It's self-defeating at that point. If you just want to test the method signatures and you've managed to stay decoupled from HttpContext (or can mock it), perhaps you're better off invoking the controllers directly from your test code. Else, send it across the wire. That's the only true way to guarantee successful integration.David L– David L2015年05月29日 16:11:50 +00:00Commented May 29, 2015 at 16:11
1 Answer 1
The in memory HTTP Server is the answer. Does exactly what I want.
How does the In-Memory HttpServer know which WebAPI project to host?