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 twice #666

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

Fluent API allows setting the return value twice #666

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 the current tip of master, a964fa7) possible:

public class Foo
{
    public override string ToString() => "original";
}

var mock = new Mock<Foo>();
mock.Setup(m => m.ToString())
    .Callback(() => { })
    .Returns(() => "changed")
    .Callback(() => { })
    .CallBase();

Assert.Equal("original", mock.Object.ToString());

While apparently, the right thing happens, this shouldn't be possible: A method cannot return twice.

@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 closed this as completed Aug 28, 2018
@stakx stakx removed this from the 4.10.0 milestone 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