首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >自动安装- fixture.CreateAnonymous<MyController>()失败测试与非法请求异常

自动安装- fixture.CreateAnonymous<MyController>()失败测试与非法请求异常
EN

Stack Overflow用户
提问于 2016-01-20 10:14:04
回答 1查看 223关注 0票数 0

我试着用自动夹具来测试我的Mvc控制器的代码:-

代码语言:javascript
运行
复制
 var fixture = new Fixture().Customize(new AutoMoqCustomization());
 fixture.Customize<ViewDataDictionary>(vdd => vdd.Without(x => x.ModelMetadata));
 var sut = fixture.CreateAnonymous<MyController>();

,它引发以下异常

代码语言:javascript
运行
复制
Exception has been thrown by the target of an invocation.
The method or operation is not implemented.

在谷歌搜索了一下之后,这似乎可以归结为使用MVc4和更高版本,并且修复方法是将定制行更改为

代码语言:javascript
运行
复制
fixture.Customize<ControllerContext>(vdd => vdd.Without(x => x.DisplayMode));

现在,这引发了一个新的异常

代码语言:javascript
运行
复制
A request for an IntPtr was detected. 
This is an unsafe resource that will crash the process if used, so the
request is denied. A common source of IntPtr requests are requests for
delegates such as Func<T> or Action<T>. If this is the case, the expected
workaround is to Customize (Register or Inject) the offending type by
specifying a proper creational strategy.

我现在似乎被困住了。

还有其他人来解决这个问题吗?或者知道另一种方法可以方便地固定我的控制器?

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-01-28 13:25:52

这是因为我的.package文件告诉我我使用的是AutoFix3.39.0,但是这个测试项目实际上引用了2.0.0。

卸载旧版本,从解决方案中删除并重新添加已解决的问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34897164

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档