You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This code was working on dotnet Core 3.1, AutoMocker 2.0.1: var mockSet = mocker.GetMock<DbSet<MyClass>>(); DbSet<T> is declared in Microsoft.EntityFrameworkCore.
That line doesn't work in later versions of AutoMocker. They throw the following exception:
Message:
System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
----> System.ArgumentNullException : Value cannot be null. (Parameter 'type')
Stack Trace:
RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture)
Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
ProxyGenerator.CreateClassProxyInstance(Type proxyType, List`1 proxyArguments, Type classToProxy, Object[] constructorArguments)
ProxyGenerator.CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, Object[] constructorArguments, IInterceptor[] interceptors)
CastleProxyFactory.CreateProxy(Type mockType, IInterceptor interceptor, Type[] interfaces, Object[] arguments) line 56
Mock`1.InitializeInstance() line 322
Mock`1.OnGetObject() line 340
Mock.get_Object() line 182
Mock`1.get_Object() line 294
GetMyFileProcessorTests.Setup() line 43
--ArgumentNullException
IntrospectionExtensions.GetTypeInfo(Type type)
DbContext.ctor(DbContextOptions options)
SurrogateContext.ctor(DbContextOptions`1 options) line 11
SurrogateContextProxy.ctor(IInterceptor[] , DbContextOptions`1 options)
Checking out other issues, I saw the enablePrivate: true argument and gave that a try in v2.3, just in case. But it didn't help.
Is there a workaround?
Thanks!
The text was updated successfully, but these errors were encountered:
GetMock<DbSet<MyClass>>(true)does work. The problem was that enablePrivate: true exposed another error further down my Setup() and I assumed it was the same exception.
But this time, replacing x = mocker.GetMock with x = new Mock followed by mocker.Use(x) did the trick.
Hi,
This code was working on dotnet Core 3.1, AutoMocker 2.0.1:
var mockSet = mocker.GetMock<DbSet<MyClass>>();
DbSet<T>
is declared in Microsoft.EntityFrameworkCore.That line doesn't work in later versions of AutoMocker. They throw the following exception:
Checking out other issues, I saw the
enablePrivate: true
argument and gave that a try in v2.3, just in case. But it didn't help.Is there a workaround?
Thanks!
The text was updated successfully, but these errors were encountered: