Verify a method was called on another object

SpecsFor includes an auto-mocking container that will automatically create mock objects for you using the excellent Moq library. You can then retrieve those mock objects and verify that a method was (or was not!) called by your system under test:

[Test]
            public void then_it_calls_the_engine_factory()
            {
                GetMockFor<IEngineFactory>()
                    .Verify(x => x.GetEngine("V8"));
            }

Did this page help you?