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!");
Était-ce utile?

La 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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top