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

Warn that delegates can not be configured to call base method at configuration time, not invocation #1492

Closed
blairconrad opened this issue Nov 11, 2018 · 3 comments

Comments

@blairconrad
Copy link
Member

blairconrad commented Nov 11, 2018

This passes, but it'd be better to fail on "When I invoke it" "And I configure it to call its base method".

[Scenario]
public static void CannotBeConfiguredToCallBaseMethod(Action fake, Exception exception)
{
    "Given a fake delegate"
        .x(() => fake = A.Fake<Action>());

    "And I configure it to call its base method"
        .x(() => A.CallTo(() => fake.Invoke()).CallsBaseMethod());

    "When I invoke it"
        .x(() => exception = Record.Exception(() => fake.Invoke()));

    "Then it throws"
        .x(() => exception.Should()
            .BeAnExceptionOfType<NotSupportedException>()
            .WithMessage("Can not configure a delegate proxy to call base method."));
}
@thomaslevesque
Copy link
Member

but it'd be better to fail on "When I invoke it".

I assume you mean that it would be better to fail on "And I configure it to call its base method"? It currently fails on "When I invoke it".

@blairconrad
Copy link
Member Author

blairconrad commented Nov 13, 2018

Sigh. Of course. How embarrassing. Classic Blair.

@thomaslevesque
Copy link
Member

This change has been released in FakeItEasy 5.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants