Using Moq to determine if a method is called
You can see if a method in something you have mocked has been called by using Verify, e.g.: static void Main(string[] args) { Mock<ITest> mock = new Mock<ITest>(); ClassBeingTested testedClass = new ClassBeingTested(); testedClass.WorkMethod(mock.Object); mock.Verify(m => m.MethodToCheckIfCalled()); } class ClassBeingTested { public void WorkMethod(ITest test) { //test.MethodToCheckIfCalled(); } } public interface ITest { void MethodToCheckIfCalled(); … Read more