I'm looking to test a method that uses code from a third party dependency. This dependency defines and interface - IPublishedContent - that is passed a parameter to the method I want to test.
Within my method I'm calling a method on IPublishedContent called GetPropertyValue. However this method isn't defined directly on the interface, it's added in by an extension method also provided by the third party dependency.
Given that, I can't use Moq as I normally would to mock the extension method.
Instead I figured I would create a stub class that implements IPublishedContent, and pass an instance of that as the parameter in my test. I added the method I want to test as an instance method on my stub.
Now, my understanding was that if I have an instance method and an extension method with the same signature, it's the instance method that gets called.
But apparently not in my test - if I put a break point on the instance method in my stub it never gets called, and the test fails with an error as it's still calling into the third party extension method.
Can anyone explain why this should be the case? I'm aware of, though not used, Microsoft Fakes (using a shim) which might be the way to solve this problem. But I can't see why this stubbing method isn't working. Thanks.