作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试为自定义 ServiceAuthorizationManager 编写单元测试。对 CheckAccessCore 的调用将 OperationContext 作为参数。要实例化 OperationContext,必须将 IContextChannel 传递给构造函数。使用 MOQ,我声明了一个 IContextChannel:
private OperationContext _context;
private Mock<IContextChannel> _contextChannelMock;
然后我尝试创建 OperationContext:
_context = new OperationContext(_contextChannelMock.Object);
但是这一行抛出异常:
Result Message: Initialization method Urs.EnterpriseServices.Providers.Tests.UrsServiceAuthorizationManager_Tests.SetUp threw exception. System.InvalidOperationException: System.InvalidOperationException: Invalid IContextChannel passed to OperationContext. Must be either a server dispatching channel or a client proxy channel..
如何模拟服务器调度 channel ?
最佳答案
你不能直接。查看是否 WCFMock会有帮助。
关于c# - 您如何在 WCF ServiceAuthorizationManager 中模拟 IContextChannel?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16285332/
我是一名优秀的程序员,十分优秀!