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

Allow calls to faked abstract methods when using callsBaseMethods #15

Closed
blairconrad opened this issue Jun 4, 2018 · 1 comment
Closed

Comments

@blairconrad
Copy link
Contributor

Currently, this code

using (var fake = new AutoFake(callsBaseMethods: true)) 
{ 
    var bar = fake.Resolve<Bar>(); 
    bar.GoAbstractly(); 
} 

(where GoAbstractly is an abstract method) throws a System.NotImplementedException:

This is a DynamicProxy2 error: The interceptor attempted to 'Proceed' for method 'Void GoAbstractly()' which is abstract. When calling an abstract method there is no implementation to 'proceed' to and it is the responsibility of the interceptor to mimic the implementation (set return value, out arguments etc.)

It's possible that this is the intended result, but it's unlikely. If the user wants to ensure that GoAbstractly is not called, better to make the fake strict or explicitly configure GoAbstractly. In modern FakeItEasy (3.0.0+), creating a Fake Bar and invoking GoAbstractly would not throw, but would return a Dummy (if the method is non-void). The same applies even if the Fake were created with (options => options.CallBaseMethods()).

@blairconrad
Copy link
Contributor Author

Thanks for the merge!

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

No branches or pull requests

1 participant