public MethodCalledEventArgs(MethodInfo method, object[] arguments) { Contract.Requires(method != null, "method should not be null."); Contract.Requires(arguments != null, "method should not be null."); Method = method; Arguments = arguments; ObservedCall = new ObservedCall(method, arguments); }
public void VerifyForUnexpectedCall(ICollection<ExpectedCall> expectedCalls, ObservedCall actualCall) { if (_behavior != MockBehavior.Strict) return; if (!IsCallExpected(expectedCalls, actualCall)) { var error = _errorFormatter.FormatNotExpectedCallsInStrictMode(expectedCalls, new[] {actualCall}); throw new VerificationException(error); } }
private bool IsCallExpected(IEnumerable<ExpectedCall> expectedCalls, ObservedCall actualCall) { // Call is unexpected if we don't have any matched calls (not counting times) foreach(var expectedCall in expectedCalls.Where(ac => ac.Method == actualCall.Method)) { if (expectedCall.MatchArguments(actualCall.Arguments)) return true; } return false; }