You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using Moq;publicclassProgram{publicinterfaceB{}publicinterfaceA:B{}publicstaticvoidMain(){Mock<A>a=newMock<A>();// a.As<A>(); // workaroundBb= a.Object;Mock<B>mockb= Mock.Get(b);Mock<A>c= mockb.As<A>();// throws}}
The line to assign c fails with an InvalidOperationException because it doesn't think the mock that wraps B implements A. Note that uncommenting the 'workaround' line fixes the problem.
The workaround makes me think this is a bug rather than intended behavior.
The text was updated successfully, but these errors were encountered:
To be honest, I'm not sure whether to classify this as a "bug", or as an "enhancement". But I'm happy to go along with your suggestion that this is a bug.
Consider this code:
The line to assign
c
fails with anInvalidOperationException
because it doesn't think the mock that wrapsB
implementsA
. Note that uncommenting the 'workaround' line fixes the problem.The workaround makes me think this is a bug rather than intended behavior.
The text was updated successfully, but these errors were encountered: