Skip to content
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

Fluent API allows setting the return value and throwing an exception at the same time #665

Closed
stakx opened this issue Aug 28, 2018 · 1 comment
Labels

Comments

@stakx
Copy link
Contributor

stakx commented Aug 28, 2018

This is currently (as of version 4.9.0) possible:

var mock = new Mock<object>();
mock.Setup(m => m.ToString())
    .Returns(() => "some string")
    .Callback(() => { })
    .Throws<Exception>();

This obviously doesn't make any sense at all: A regular method cannot return a value and throw an exception at the same time, so this shouldn't be possible in Moq either.

@stakx
Copy link
Contributor Author

stakx commented Aug 28, 2018

This will be tracked in #668 along with some other closely related issues.

@stakx stakx removed this from the 4.10.0 milestone Aug 28, 2018
@stakx stakx closed this as completed Aug 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant