I've created a new solution with WCF REST services. Now I need to unit test the services. For example, here's a REST service url:
cars/{id}
The GET method should return a car object with the id provided in the querystring. How can I configure through a VS unit test project?
Simple, create a self-hosted unit test, i.e.
[TestInitialize]
public void Before_Each_Test()
{
var host = new ServiceHost(typeof(CarService));
// Override with local endpoint, i.e. a TCP connection, local IP etc
host.Open();
}
Then dont forget to shut down the host in TestCleanup, of course.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments