I am planning to unit test WCF Services that are exposed as .svc files. What are the best practices available to unit test them.
As for as i know this is the option available:
Create a seperate project and have proxy classes created for the .svc files and add them to the project and do unit testing on those proxy classes.
Proxy classes can be created using:
- svcutil.exe
- “Add Service Reference” option of visual studio.
are there any other best option available to unit test my wcf .svc file using nunit?
Basically, you don’t unit test the services. You unit test their code, just as though that code were not in a service.
Don’t even create an instance of the service class. That’s too big a thing to unit test. You would unit test the code within that class. Remember that unit tests are meant to test the smallest possible units of your code, not the entire service.