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, ie
[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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.