private bool Matches(ICall call, CallSpecAndTarget specAndTarget)
 {
     return ReferenceEquals(call.Target(), specAndTarget.Target)
            && specAndTarget.CallSpecification.IsSatisfiedBy(call);
 }
        private string FormatCallSpec(CallSpecAndTarget callSpecAndTarget, bool isAcrossMultipleTargets, TypeInstanceNumberLookup instanceLookup)
        {
            var s = callSpecAndTarget.CallSpecification.ToString();
            if (!isAcrossMultipleTargets) return s;

            var target = callSpecAndTarget.Target;
            var methodInfo = callSpecAndTarget.CallSpecification.GetMethodInfo();
            return FormatCallForInstance(instanceLookup, target, methodInfo, s);
        }
 private string GetExceptionMessage(CallSpecAndTarget[] querySpec, ICall[] matchingCallsInOrder)
 {
     const string callDelimiter = "\n    ";
     var instanceLookup = new TypeInstanceNumberLookup();
     var isAcrossMultipleTargets = IsAcrossMultipleTargets(querySpec);
     var formattedQuery = string.Join(callDelimiter,
                                      querySpec.Select(x => FormatCallSpec(x, isAcrossMultipleTargets, instanceLookup)).ToArray());
     var formattedCalls = string.Join(callDelimiter,
                                      matchingCallsInOrder.Select(x => FormatCall(x, isAcrossMultipleTargets, instanceLookup)).ToArray());
     return string.Format("\nExpected to receive these calls in order:{0}{1}\n" +
                          "Actually received matching calls in this order:{0}{2}\n\n{3}",
                          callDelimiter,
                          formattedQuery,
                          formattedCalls,
                          "*** Note: calls to property getters are not considered part of the query. ***");
 }
 private bool IsAcrossMultipleTargets(CallSpecAndTarget[] querySpec)
 {
     if (!querySpec.Any()) return false;
     var firstTarget = querySpec.First().Target;
     return querySpec.Any(x => !ReferenceEquals(firstTarget, x.Target));
 }