I\'m using the beta of Microsoft Fakes in Visual Studio 11. How can I verify that a dependency\'s method was called by my system under test?
Another option that you have for doing behavioral verification with the Microsoft Fakes framework is to use the StubObserver class thats included in the Microsoft.QualityTools.Testing.Fakes.Stubs namespace. Using the framework, you generate a stub for your dependency. Then on your Stub you can set the InstanceObserver property to a new StubObserver. Using the StubObserver class, you can "query" the method calls made to your dependency. Your test method would look something like below
//Arrange
var dependency = new StubIDependency { InstanceObserver = new StubObserver() };
var sut = new SystemClass(dependency);
// Act
sut.DoSomething();
// Assert
var observer = (StubObserver)dependency.InstanceObserver;
Assert.IsTrue(
observer.GetCalls().Any(call => call.StubbedMethod.Name == "DoSomething"));