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
This issue went unaddressed on Google Code No. 293, but I'd like to see this change. I want to set MockBehavior.Strict so that when a test fails for lack of a mocked method/property, the error message tells me exactly what's missing. Under MockBehavior.Loose, it's a bit of a goose chase to figure out sometimes.
In my particular case right now, I have:
public abstract class A
{
public abstract void DoThis();
public abstract void DoThat();
}
public abstract class B : A
{
public override void DoThis()
{
// Doing this...
}
}
I really want to just let my Mock<B> call B.DoThis(), but with MockBehavior.Strict so I'll know exactly when/where Mock<B>.DoThat() gets called.
For now, my workaround is to use MockBehavior.Loose, override in B, and throw NotImplementedExceptions:
...
public override void DoThat()
{
throw new NotImplementedException();
}
...
This gets me to the desired behavior, but it's a lot more work than it seems like it ought to be.
The text was updated successfully, but these errors were encountered:
@aggieben: Your issue turned 2 years old recently, but if you would still like to have it looked into, may I ask you to please provide a clearer description of what you were trying to do (including short but complete repro code), and where Moq didn't meet your expectations.
For one thing, I am not sure why you linked to that Google thread, it seems like an altogether different issue. The Google Code issue asks for a method-specific CallBase, your issue seems to revolve around MockBehavior.Strict.
Second, it is also not clear from your code example why a call to mock.DoThis() should ever result in Mock<B>.DoThat() getting invoked. You have neither specified that behavior in the mocked class, nor as a setup.
If you are no longer interested in this issue, you don't need to reply, and I'll close it in 1-2 weeks. If it just takes you longer respond, that's not a problem, we can always reopen the issue.
This issue went unaddressed on Google Code No. 293, but I'd like to see this change. I want to set
MockBehavior.Strict
so that when a test fails for lack of a mocked method/property, the error message tells me exactly what's missing. UnderMockBehavior.Loose
, it's a bit of a goose chase to figure out sometimes.In my particular case right now, I have:
I really want to just let my
Mock<B>
call B.DoThis(), but withMockBehavior.Strict
so I'll know exactly when/whereMock<B>.DoThat()
gets called.For now, my workaround is to use
MockBehavior.Loose
, override in B, and throwNotImplementedExceptions
:This gets me to the desired behavior, but it's a lot more work than it seems like it ought to be.
The text was updated successfully, but these errors were encountered: