I wanted to create a test class for a WCF service. I believe "mocking" is the right term for this?
I'm not really sure that the way i think i have to do this is the correct way. I have been given a URL to a WCF service, for example:
http:://somesite.com/wcf/RealService.svc
And:
http:://somesite.com/wcf/RealService.svc?wsdl
So instead of actually adding the RealService.svc
to my project as Service Reference
i simply added a new empty WCF Service
to my project called Service1
.
I then want to use the wsdl.exe
(or maybe the svcutil.exe?) tool to generate an interface from the WSDL url: http:://somesite.com/wcf/RealService.svc?wsdl
.
I then open the Service1.cs
file and instead of letting is inherit from IService1.cs
i let it inherit from the generated interface
.
Then instead of calling the real service in my application i simply call my Service1
class. Is that how mocking a web service works..?
Also need to figure out how to actually generate an interface
with the svcutil tool (i've read that i can't use wsdl.exe for a WCF service?). So any tips on that are more than welcome aswell!