Is it posible to test a WebApi service without opening a network port

Topics: Web Api
Jul 7, 2011 at 9:21 PM

I woud like to create integration style tests in which I test my configuration of custom operation handlers, formatters, channels as well as the resource. The HttpConfigurableServiceHost seams like a nice way to achieve this but it requeres specifying an unused port in the uri. It would be easy to start getting failed tests if this port was already in use.

Is it posible to test a WebApi service without opening a network port. So I would create and configure the HttpServiceHost but instead of opening the connection and listening for requests I just call an method with a HttpRequest and receive an HttpResponse back.

Jul 7, 2011 at 10:46 PM

A future version is expected to include an in-memory host.  That should address your requirements nicely.

Jul 7, 2011 at 10:53 PM
Thats great news. Sounds just what I wanted.

Sent from my iPhone