0

I am new to UnitTesting. Can any one please tell me, how to do server side unit Test where we expose our service in WCF Service with Mocking objects.

NomadTraveler
  • 1,086
  • 1
  • 12
  • 37

2 Answers2

0

autofixture or nbuilder libraries helps you to generate mock up data

Ram
  • 57
  • 2
  • 10
0

When you are using WCF you have full separation of service logic and communication infrastructure. So you can easily make tests for service logic like you are doing for regular classes. Also you can write unit tests for infrastructure to check that everything is set up right.

  • Yes, I do have seperation both service expose logic and service consume logic. But how to mock the service class(proxy class added as a service reference) and to do the unit test for the same service class method. – Prakash Muthukrishnan Sep 25 '13 at 12:21
  • 1) If you want to unit test WCF service logic you don't need to call it via proxy, you can test your plain class with service implementation. 2) If you want to unit test some method in some class where your WCF service method is called you can do that for example such way - you can pass interface of your WCF service in constructor and use it via interface, in application code you pass WCF service proxy there and in unit test you can pass some fake implementation of your WCF service interface (you can do it by hand or using some framework like Moq, NSubstitute, MS Fakes). – Oleksandr Kobylianskyi Sep 26 '13 at 07:42