-
Notifications
You must be signed in to change notification settings - Fork 183
-
Notifications
You must be signed in to change notification settings - Fork 183
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
investigate interaction between Implements
and CallsBaseMethods
#463
Comments
Interesting. This seems like a bug. |
Indeed. Probably something like Note: I have not looked. I'm just guessing. Of course, even if this is true, I wonder if we wouldn't need to investigate method equality on the matchers. Should a call to |
public static IFakeOptions<T> CallsBaseMethods<T>(this IFakeOptions<T> options)
{
Guard.AgainstNull(options, nameof(options));
return options.ConfigureFake(fake => A.CallTo(fake)
.Where(call => !call.Method.IsAbstract)
.CallsBaseMethod());
} Not sure how to fix it, though. |
Here's a similar scenario that is more worrying: public interface IInterface
{
void DoSomething();
}
public abstract class AbstractClass
{
public void DoSomething()
{
Console.WriteLine("Got here");
}
}
public void Test()
{
var fake = (IInterface)A.Fake<AbstractClass>(builder => builder
.Implements(typeof(IInterface))
.CallsBaseMethods());
A.CallTo(() => fake.DoSomething()).CallsBaseMethod();
fake.DoSomething();
} This code throws:
|
Apparently |
Am I oversimplifying, or does this whole issue boil down to:
? |
I think your analysis is correct, but to be honest, I'm no longer sure of anything about this issue... |
I'm coming to believe that it's not a bug. It's just the way |
Sounds good to me. 👍 for not fixing, since it's not broken. |
fakeDoSomething
does not callAbstractClass.DoSomething
, no matter in which order theImplements
andCallsBaseMethods
are used.However,
does call
AbstractClass.DoSomething
.Omitting the
(IOtherInterface)
cast also causesAbstractClass.DoSomething
to be executed:Found while investigating an answer to Having an interface fake inherit from abstract while both share same interface inheritance.
The text was updated successfully, but these errors were encountered: