【问题标题】:How to mock an interface implementing ChannelFactory如何模拟实现 ChannelFactory 的接口
【发布时间】:2014-01-08 16:23:59
【问题描述】:

这是我用来通过接口IService1调用我的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 模拟服务调用?

【问题讨论】:

    标签: mocking nunit channelfactory


    【解决方案1】:

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

    【讨论】:

    • 我们目前正在使用moq框架...可以用moq做吗
    • 任何使用起订量的解决方案
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-01
    • 2021-09-03
    • 1970-01-01
    • 2010-11-19
    • 1970-01-01
    相关资源
    最近更新 更多