I'm trying to use Autofixture to test my Mvc controller with this code:-
var fixture = new Fixture().Customize(new AutoMoqCustomization());
fixture.Customize<ViewDataDictionary>(vdd => vdd.Without(x => x.ModelMetadata));
var sut = fixture.CreateAnonymous<MyController>();
which throws the following exception
Exception has been thrown by the target of an invocation.
The method or operation is not implemented.
After some googling around this seems to be down to using MVc4 and above, and the fix was to change the Customize line to
fixture.Customize<ControllerContext>(vdd => vdd.Without(x => x.DisplayMode));
Hoever this now throws a new exception
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.
I now seem to be stuck.
Has anyone else come accross this problem and solved it? Or know of a different way to easily fixturize my controller?
Thanks