开发者

pass Business Layer to WCF service

开发者 https://www.devze.com 2023-03-11 02:14 出处:网络
I have a WCF service and i am trying to write unit test cases for that. I am calling Business Layer and some other WCF service from one of the methods in that service. I am already using IcO pattern f

I have a WCF service and i am trying to write unit test cases for that. I am calling Business Layer and some other WCF service from one of the methods in that service. I am already using IcO pattern for my Business Layer. but in order to use Mock object of my Business Layer and WCF service here, i need to pass it at the time of creating that service instance. If i change my default constructor to accept it as a parameter, i will have to expose them to the service consumers.

if i change the constructor of the service, it will look like this:

public MyService(MyBusinessLayer bl, SomeWCFService otherSrvc)
{

}

Is it OK to开发者_开发技巧 do so? Am i doing something wrong here?


Send an interface of the service instead of an impementation. That way you can swap out the implementation at runtime with your mock.

0

精彩评论

暂无评论...
验证码 换一张
取 消