如何模拟实现ChannelFactory的接口

时间:2014-01-08 16:23:59

标签: mocking nunit channelfactory

这是我用来通过接口IService1.Which实现通道工厂调用我的wcf服务方法(GetCountry)的方法

public IList<Country> GetCountry()
{
   ChannelFactory<ServiceLibrary.IService1> channelFactory = new               ChannelFactory<IService1>(binding, address);

   IService1 channel1 = channelFactory.CreateChannel();

   var response= channel1.GetCountry();

   return response;
}

如何使用NUNIT模拟服务调用?

1 个答案:

答案 0 :(得分:1)

你不能直接嘲笑。使用任何模拟框架并隔离服务调用并通过一些虚拟值获取服务结果 Isolate.whencalled.willReturn(serviceValue)