Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 9478bea9f9
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 56 lines (45 sloc) 1.321 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
//
// LRInvocationComparitor.m
// Mocky
//
// Created by Luke Redpath on 27/07/2010.
// Copyright (c) 2010 LJR Software Limited. All rights reserved.
//

#import "LRInvocationComparitor.h"
#import "NSInvocation+OCMAdditions.h"
#import "LRHamcrestSupport.h"


@implementation LRInvocationComparitor

+ (id)comparitorForInvocation:(NSInvocation *)invocation;
{
  return [[[self alloc] initWithInvocation:invocation] autorelease];
}

- (id)initWithInvocation:(NSInvocation *)anInvocation;
{
  if (self = [super init]) {
    expectedInvocation = [anInvocation retain];
    [expectedInvocation retainArguments];
  }
  return self;
}

- (void)dealloc
{
  [expectedInvocation release];
  [super dealloc];
}

- (BOOL)matchesParameters:(NSInvocation *)invocation;
{
  NSMethodSignature *methodSignature = [expectedInvocation methodSignature];
  
  BOOL matchesParameters = YES;
  for (int i = 2; i < [methodSignature numberOfArguments]; i++) {
    id expected = [expectedInvocation getArgumentAtIndexAsObject:i];
    id received = [invocation getArgumentAtIndexAsObject:i];

    if ([expected conformsToProtocol:NSProtocolFromString(@"HCMatcher")]) {
      matchesParameters = [expected matches:received];
    }
    else {
      matchesParameters = [expected isEqual:received];
    }
  }
  return matchesParameters;
}

@end
Something went wrong with that request. Please try again.