我试着用自动夹具来测试我的Mvc控制器的代码:-
var fixture = new Fixture().Customize(new AutoMoqCustomization());
fixture.Customize<ViewDataDictionary>(vdd => vdd.Without(x => x.ModelMetadata));
var sut = fixture.CreateAnonymous<MyController>();
,它引发以下异常
Exception has been thrown by the target of an invocation.
The method or operation is not implemented.
在谷歌搜索了一下之后,这似乎可以归结为使用MVc4和更高版本,并且修复方法是将定制行更改为
fixture.Customize<ControllerContext>(vdd => vdd.Without(x => x.DisplayMode));
现在,这引发了一个新的异常
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.
我现在似乎被困住了。
还有其他人来解决这个问题吗?或者知道另一种方法可以方便地固定我的控制器?
谢谢
发布于 2016-01-28 13:25:52
这是因为我的.package文件告诉我我使用的是AutoFix3.39.0,但是这个测试项目实际上引用了2.0.0。
卸载旧版本,从解决方案中删除并重新添加已解决的问题。
https://stackoverflow.com/questions/34897164
复制相似问题