We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The exception: System.Reflection.TargetInvocationException with the message " Exception has been thrown by the target of an invocation."
Is thrown during a call to VerifySet when code in a classes constructor references a property of this
This code reproduces the exception
[TestMethod] public void Broken_moq() { var sut = Mock.Of<Example>(); Mock.Get(sut).VerifySet(x => x.A = "A", Times.Never); } public class Example { public virtual string A { get; set; } public virtual string B { get; set; } public Example() { A = ""; B = this.A; } }
The test above should run without throwing an exception
Recorder.Intercept(Invocation invocation) line 413 Interceptor.Intercept(IInvocation underlying) line 218 AbstractInvocation.Proceed() ExampleProxy_1.get_A() Example.ctor() line 124 ExampleProxy_1.ctor(IInterceptor[] ) --- End of inner exception stack trace --- RuntimeMethodHandle.InvokeMethod(Object target, Span`1& 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 110 ActionObserver.CreateProxy(Type type, Object[] ctorArgs, MatcherObserver matcherObserver, Recorder& recorder) line 275 ActionObserver.ReconstructExpression[T](Action`1 action, Object[] ctorArgs) line 53 Mock`1.VerifySet(Action`1 setterExpression, Func`1 times) line 1236
4.20.70
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The exception: System.Reflection.TargetInvocationException with the message " Exception has been thrown by the target of an invocation."
Is thrown during a call to VerifySet when code in a classes constructor references a property of this
Steps to Reproduce
This code reproduces the exception
Expected Behavior
The test above should run without throwing an exception
Exception with Stack Trace
Version Info
4.20.70
The text was updated successfully, but these errors were encountered: