0

Just wanted to know whether we can have a Unit Test Project dedicated to a WCF Solution or not ? I know this might be a Generic question but I couldn't get specific answer to it even though I searched through various blogs and websites. Please suggest.

Nayan_07
  • 195
  • 1
  • 4
  • 13
  • 1
    what do you mean 'dedicated to a WCF solution'? Do you want to unit test a WCF service? Maybe an example of what you mean might be good? – Sam Holder Apr 28 '15 at 09:04
  • Hi Sam,We have created a WCF Service. We want to create a Unit Test Project for this Solution. Please suggest. – Nayan_07 Apr 28 '15 at 09:26
  • http://stackoverflow.com/questions/15154735/testing-a-wcf-web-service – JakubJ Apr 28 '15 at 09:34

1 Answers1

1

yes its possible to unit test WCF services. The options are:

  • create classes which do all of the work which are separate from the WCF service. Unit test these classes in isolation. Make your service a thin wrapper which calls these classes.
  • test directly with the WCF service class without it being hosted (a bit like this example)
  • Have the unit tests host the WCF service in process and then call the services via named pipes or similar (see the console example here for details of how to self-host). When you self host you should start the service in the test setup or the test fixture setup and then destroy it in the corresponding teardown.
Sam Holder
  • 32,535
  • 13
  • 101
  • 181