public static string Describe(this IAssertionCall @this) { var matchersDescriptions = @this .ArgumentMatchers .Select(m => m.Describe()); return(new StringBuilder() .Append(@this.Mock.Name) .Append('.') .Append(@this.Method.Name) .Append('(') .Append(string.Join(", ", matchersDescriptions)) .Append(')') .ToString()); }
public void Check(IAssertionCall assertionCall, IMethodCallHistory methodCallHistory) { var matcher = assertionCall.ToMethodCallMatcher(); int matchingCallsCount = methodCallHistory .GetCalledMethods() .Where(matcher.MatchesCall) .Count(); if (matchingCallsCount != _times) { throw new SubstituteException( $"Expected *{_times}* call(s) matching assertion:\n" + $"\t{assertionCall.Describe()}\n" + $"but got *{matchingCallsCount}* matching calls."); } }
public void Check(IAssertionCall assertionCall, IMethodCallHistory methodCallHistory) { var anyArgsAssertionCall = new AnyArgumentsAssertionCall(assertionCall); var matcher = anyArgsAssertionCall.ToMethodCallMatcher(); int matchingCallsCount = methodCallHistory .GetCalledMethods() .Where(matcher.MatchesCall) .Count(); // TODO: Add proxy name and full method signature to error message. // Put signature at the end (to not clutter error message). if (matchingCallsCount == 0) { throw new SubstituteException( $"Expecting to receive at least a single call to method " + $"{anyArgsAssertionCall.Describe()} " + $"but none was received."); } }
public AnyArgumentsAssertionCall(IAssertionCall callWithAnyArgs) { Mock = callWithAnyArgs.Mock; Method = callWithAnyArgs.Method; ArgumentMatchers = GenerateAnyMatchers(callWithAnyArgs.Method); }
public static IMethodCallMatcher ToMethodCallMatcher(this IAssertionCall @this) { return(new MethodCallMatcher(@this.Method, @this.ArgumentMatchers)); }