Question

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!");
Was it helpful?

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top