Hi there,
I've just upgraded to 1.51 (previously I was on version 1.2), and I've just started getting the following error:
"A matching constructor for the given arguments was not found on the mocked type."
The stack trace is:
System.MissingMethodException: Constructor on type 'System.Web.Hosting.VirtualPathProvider' not found.
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at Moq.RemotingProxy..ctor(Type targetType, Action`1 interceptor, Object[] ctorArgs)
at Moq.Mock`1..ctor(MockBehavior behavior, Object[] args)
System.ArgumentException: A matching constructor for the given arguments was not found on the mocked type.
at Moq.Mock`1..ctor(MockBehavior behavior, Object[] args)
at Moq.Mock`1..ctor()
at OpinionatedGeek.Applications.Tests.PathTests.GetVirtualPathProviderMock()
My code, which hasn't changed for 1.51, is pretty simple:
private static Mock<VirtualPathProvider> GetVirtualPathProviderMock ()
{
return new Mock<VirtualPathProvider> (MockBehavior.Strict);
}
My guess (from a brief look at the Moq code) is that it's because VirtualPathProvider is both abstract and MarshalByRefObject.
So, is this a bug in Moq or am I doing something wrong?
Many thanks,
Geoff
Yep, I think that's the 'right' answer (although it's overkill for my current situation).
Cheers,
Geoff
Hi,
Wasn't sure if you wanted an issue raised or not. It's done now (with some simple sample code) at: