[c#] Using Moq to determine if a method is called

0 Answers

No, mock testing assumes you are using certain testable design patterns, one of which is injection. In your case you would be testing SomeClass.SomeMethod and SomeOtherMethod must be implemented in another entity which needs to be interfaced.

Your Someclass constructor would look like New(ISomeOtherClass). Then you would mock the ISomeOtherClass and set expectation on its SomeOtherMethod to be called and verify the expectation.


It is my understanding that I can test that a method call will occur if I call a higher level method, i.e.:

public abstract class SomeClass()
    public void SomeMehod()

    internal abstract void SomeOtherMethod();

I want to test that if I call SomeMethod() then I expect that SomeOtherMethod() will be called.

Am I right in thinking this sort of test is available in a mocking framework?