-
-
Notifications
You must be signed in to change notification settings - Fork 794
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
Issue on Dispose when using a Mock and Strict behavior (After 4.2.1402.2112) #143
Comments
Duplicate of #129 |
CallBase may be missing, and as noted on #129, you should set up the main /kzu from mobile
|
Copied open new report from here -- http://code.google.com/p/moq/issues/detail?id=379&start=100
What steps will reproduce the problem?
Mock mockWebClient = new Mock(MockBehavior.Strict);
mockWebClient.Protected().Setup("Dispose", ItExpr.IsAny());
using (WebClient client = mockWebClient.Object))
{
}
What is the expected output? What do you see instead?
It should work without error. But starting with the version 4.2.1408.619, I have an exception:
Test method XXX threw exception:
Moq.MockException: IDisposable.Dispose() invocation failed with mock behavior Strict.
All invocations on the mock must have a corresponding setup.
Result StackTrace:
at Moq.ExtractProxyCall.HandleIntercept(ICallContext invocation, InterceptorContext ctx, CurrentInterceptContext localctx)
at Moq.Interceptor.Intercept(ICallContext invocation)
at Moq.Proxy.CastleProxyFactory.Interceptor.Intercept(IInvocation invocation)
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at Castle.Proxies.WebClientProxy.Dispose()
at ...
The problem being that I can't mock the Dispose() method, it's not virtual. The Dispose method calls the protected virtual Dispose(bool) method, so my way should be the correct one.
Previously, I was using the version 4.2.1312.1622 and it was working correctly.
I tested all versions available on Nuget from 4.2.1312.1622 to 4.2.1408.717 (latest at the moment), and it stopped working at the version 4.2.1408.619.
What version of the product are you using? On what operating system?
Works correctly with nuget versions: 4.2.1312.1622, 4.2.1402.2112
Doesn't work with nuget versions: 4.2.1408.619, 4.2.1408.717 (latest ATM)
My operating system is Windows 7, I tested with Frameworks 4, 4.5 and 4.5.1
Please provide any additional information below.
/
Thank you
The text was updated successfully, but these errors were encountered: