Easy way to mock a WCF service?

前端 未结 3 456
清歌不尽
清歌不尽 2020-12-28 23:54

I\'ve got an app which is using a WCF service. Now I\'d like to add unit tests to the app.

For some cases I need to mock the WCF service, since getting the desired b

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-29 00:41

    Why can't you use something like NMock2 to mock the IMyWcfService interfaces directly?

    If you need to be able to create new instances on the fly, use the Factory to hide the ChannelFactory from the client. This way you can replace the factory, providing the client one which creates mocks instead of real proxies.

提交回复
热议问题