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

Raise exception if you try to mock a non-virtual method #131

Merged
merged 1 commit into from
Jun 10, 2021
Merged

Conversation

Laurensvanrun
Copy link
Contributor

This is a solution for "No warning or error reported for non-virtual method calls. #47"

@vincentparrett
Copy link
Member

Nice one thanks

@vincentparrett vincentparrett merged commit 8fbdd67 into VSoftTechnologies:master Jun 10, 2021
@sglienke
Copy link

sglienke commented Feb 15, 2022

To be fair the exception only gets raised at the epilogue of the routine because that is the point where the _Release gets called which triggers the exception. This might be way after any other code that relies on the mock behavior and might already fail.

I am also not sure if multiple calls to the mock might disable the exception because they will change FSetupMode.

So this might only succeed in the two synthetic tests.

Confirmed - change the test as below and it will fail:

  Assert.WillRaise(
    procedure
    begin
      mock.Setup.Expect.Once.When.NonVirtualMethod;
      mock.Setup.Expect.Once.When.VirtualMethod;
    end);

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

Successfully merging this pull request may close these issues.

None yet

3 participants