Created
June 6, 2017 21:14
-
-
Save scottheckel/60d2c9dce3eaeac37f37a61b09711729 to your computer and use it in GitHub Desktop.
Microsoft Fakes Stub Verify Method Called
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class StubBaseExtensions | |
{ | |
/// <summary> | |
/// Verify if a method was called on a stub | |
/// </summary> | |
/// <remarks>Derived from code found on http://www.peterprovost.org/blog/2012/11/29/visual-studio-2012-fakes-part-3/ </remarks> | |
/// <param name="stub">Stub</param> | |
/// <param name="methodName">Method Name</param> | |
/// <returns>True if <paramref name="methodName"/> was called</returns> | |
public static bool VerifyMethodCalled(this StubBase stub, string methodName) | |
{ | |
return ((StubObserver)stub.InstanceObserver).GetCalls().Any(call => call.StubbedMethod.Name == methodName); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment