-
-
Notifications
You must be signed in to change notification settings - Fork 803
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 on WebClient and Strict behavior #129
Comments
You should be using this: mockWebClient.As< IDisposable >().Setup(p => p.Dispose()); |
Indeed. |
dougbu
added a commit
to aspnet/AspNetWebStack
that referenced
this issue
Aug 25, 2016
- work around devlooped/moq#129 and devlooped/moq#212; Moq creates proxies for all `interface` methods - e.g. set up `IDisposable.Dispose()` calls - related bug devlooped/moq#212 means we can't use `MockBehavior.Strict` in some cases - especially when method returns a value and therefore can't be set up to call base - `CallBase = true` is often required in these cases - work around devlooped/moq#149; `DefaultValue.Mock` restrictions - where necessary, explicitly set up members instead - work around odd failures in `JsonResultTest` using `SetupSet()` on deep properties - use `MockBehavior.Strict` in `NullContentIsNotOutput()` to confirm `Write()` is not called - handle less-predictable proxy type names
dougbu
added a commit
to aspnet/AspNetWebStack
that referenced
this issue
Aug 26, 2016
- #11 (3 of 4) - work around devlooped/moq#129 and devlooped/moq#212; Moq creates proxies for all `interface` methods - e.g. set up `IDisposable.Dispose()` calls - related bug devlooped/moq#212 means we can't use `MockBehavior.Strict` in some cases - especially when method returns a value and therefore can't be set up to call base - `CallBase = true` is often required in these cases - work around devlooped/moq#149; `DefaultValue.Mock` restrictions - where necessary, explicitly set members up instead - work around odd failures in `JsonResultTest` using `SetupSet()` on deep properties - use `MockBehavior.Strict` in `NullContentIsNotOutput()` to confirm `Write()` is not called - handle less-predictable proxy type names
Thanks ! @drieseng |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
What steps will reproduce the problem?
Using this code :
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:
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.
What version of the product are you using? On what operating system?
Works correctly with versions (from nuget): 4.2.1312.1622, 4.2.1402.2112
Doesn't work with 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: