1

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"

asked May 29, 2015 at 15:25
3
  • OWIN self host is what I use for my Web API unit testing. Commented May 29, 2015 at 15:51
  • that would still send things out of process over http wouldn't it? Commented 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. Commented May 29, 2015 at 16:11

1 Answer 1

1
answered May 29, 2015 at 17:25

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.