NSObject+KiwiSpyAdditions.m 913 B

1234567891011121314151617181920212223242526272829
  1. //
  2. // Licensed under the terms in License.txt
  3. //
  4. // Copyright 2010 Allen Ding. All rights reserved.
  5. //
  6. #import "NSObject+KiwiSpyAdditions.h"
  7. #import "KWCaptureSpy.h"
  8. #import "KWMessagePattern.h"
  9. #import "NSObject+KiwiStubAdditions.h"
  10. @implementation NSObject (KiwiSpyAdditions)
  11. - (KWCaptureSpy *)captureArgument:(SEL)selector atIndex:(NSUInteger)index {
  12. KWCaptureSpy *spy = [[KWCaptureSpy alloc] initWithArgumentIndex:index];
  13. KWMessagePattern *pattern = [[KWMessagePattern alloc] initWithSelector:selector];
  14. [self addMessageSpy:spy forMessagePattern:pattern];
  15. return spy;
  16. }
  17. + (KWCaptureSpy *)captureArgument:(SEL)selector atIndex:(NSUInteger)index {
  18. KWCaptureSpy *spy = [[KWCaptureSpy alloc] initWithArgumentIndex:index];
  19. KWMessagePattern *pattern = [[KWMessagePattern alloc] initWithSelector:selector];
  20. [self addMessageSpy:spy forMessagePattern:pattern];
  21. return spy;
  22. }
  23. @end