Search code examples
visual-studio-2012microsoft-fakes

StubObserver: How to verify if stub method is called with the right paramerter?


i refer to this article from Peter Provost:

Visual Studio 2012 Fakes - Part 3 - Observing Stub Behavior

The question is if and how can i verify if the method is called with a defined parameter? For example somthing like that:

var wasCalled = observer.GetCalls().Any(call => call.StubbedMethod.Name == methodName && call.StubMethod.Parameter == "Hello there!");

Solution

  • I think this is what you need.

    var wasCalled = observer.GetCalls().Any(call => call.StubbedMethod.Name == methodName && (string)call.GetArguments() == "Hello there!");

    HTH Patrick Tseng Microsoft ALM team