-
-
Notifications
You must be signed in to change notification settings - Fork 802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mocking Abstract Class; Implements Interface; Generic Method Fails #193
Labels
Comments
I've tried newer version of Castle.core with no success. It doesn't seem to be the generic constraints causing the issue. It seems to be the generic method itself causing an issue. |
HelloKitty
changed the title
Mocking Abstract Class; Implements Interface; Generic Method + Constraints Fails
Mocking Abstract Class; Implements Interface; Generic Method Fails
Aug 3, 2015
This is an issue with Castle.core. I've found the root cause and will report it there. |
2 tasks
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi, so I have an abstract class I'm attempting to mock so I can test implemented functionality and etc.
The class implements an interface that has a generic method with two generic constraints on the Type. If I remove this interface everything works fine. However, with it left as is I fail to call the getter for Mock.Object without an exception.
Here is the stacktrace:
System.Collections.Generic.KeyNotFoundException : The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary
2.get_Item(TKey key) at Castle.DynamicProxy.Generators.Emitters.AbstractTypeEmitter.GetGenericArgumentsFor(MethodInfo genericMethod) at Castle.DynamicProxy.Generators.InvocationTypeGenerator.GetCallbackMethod(AbstractTypeEmitter invocation) at Castle.DynamicProxy.Generators.InvocationTypeGenerator.ImplementInvokeMethodOnTarget(AbstractTypeEmitter invocation, ParameterInfo[] parameters, MethodEmitter invokeMethodOnTarget, Reference targetField) at Castle.DynamicProxy.Generators.InvocationTypeGenerator.ImplemementInvokeMethodOnTarget(AbstractTypeEmitter invocation, ParameterInfo[] parameters, FieldReference targetField, MethodInfo callbackMethod) at Castle.DynamicProxy.Generators.InvocationTypeGenerator.Generate(ClassEmitter class, ProxyGenerationOptions options, INamingScope namingScope) at Castle.DynamicProxy.Contributors.ClassProxyTargetContributor.BuildInvocationType(MetaMethod method, ClassEmitter class, ProxyGenerationOptions options) at Castle.DynamicProxy.Contributors.ClassProxyTargetContributor.GetMethodGenerator(MetaMethod method, ClassEmitter class, ProxyGenerationOptions options, OverrideMethodDelegate overrideMethod) at Castle.DynamicProxy.Contributors.CompositeTypeContributor.ImplementMethod(MetaMethod method, ClassEmitter class, ProxyGenerationOptions options, OverrideMethodDelegate overrideMethod) at Castle.DynamicProxy.Contributors.CompositeTypeContributor.Generate(ClassEmitter class, ProxyGenerationOptions options) at Castle.DynamicProxy.Generators.ClassProxyGenerator.GenerateType(String name, Type[] interfaces, INamingScope namingScope) at Castle.DynamicProxy.Generators.ClassProxyGenerator.<>c__DisplayClass1.<GenerateCode>b__0(String n, INamingScope s) at Castle.DynamicProxy.Generators.BaseProxyGenerator.ObtainProxyType(CacheKey cacheKey, Func
3 factory)at Castle.DynamicProxy.Generators.ClassProxyGenerator.GenerateCode(Type[] interfaces, ProxyGenerationOptions options)
at Castle.DynamicProxy.DefaultProxyBuilder.CreateClassProxyType(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options)
at Castle.DynamicProxy.ProxyGenerator.CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, Object[] constructorArguments, IInterceptor[] interceptors)
at Moq.Proxy.CastleProxyFactory.CreateProxy(Type mockType, ICallInterceptor interceptor, Type[] interfaces, Object[] arguments)
at Moq.Mock
1.<InitializeInstance>b__2() at Moq.PexProtector.Invoke(Action action) at Moq.Mock
1.InitializeInstance()at Moq.Mock
1.OnGetObject() at Moq.Mock
1.get_Object()at
The text was updated successfully, but these errors were encountered: