NSObject+KiwiStubAdditions.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // Licensed under the terms in License.txt
  3. //
  4. // Copyright 2010 Allen Ding. All rights reserved.
  5. //
  6. #import "KiwiConfiguration.h"
  7. @class KWCaptureSpy;
  8. @class KWMessagePattern;
  9. @protocol KWMessageSpying;
  10. @protocol KiwiStubAdditions <NSObject>
  11. #pragma mark - Stubbing Methods
  12. - (void)stub:(SEL)aSelector;
  13. - (void)stub:(SEL)aSelector withBlock:(id (^)(NSArray *params))block;
  14. - (void)stub:(SEL)aSelector withArguments:(id)firstArgument, ...;
  15. - (void)stub:(SEL)aSelector andReturn:(id)aValue;
  16. - (void)stub:(SEL)aSelector andReturn:(id)aValue withArguments:(id)firstArgument, ...;
  17. - (void)stub:(SEL)aSelector andReturn:(id)aValue times:(NSNumber *)times afterThatReturn:(id)aSecondValue;
  18. + (void)stub:(SEL)aSelector;
  19. + (void)stub:(SEL)aSelector withBlock:(id (^)(NSArray *params))block;
  20. + (void)stub:(SEL)aSelector withArguments:(id)firstArgument, ...;
  21. + (void)stub:(SEL)aSelector andReturn:(id)aValue;
  22. + (void)stub:(SEL)aSelector andReturn:(id)aValue withArguments:(id)firstArgument, ...;
  23. + (void)stub:(SEL)aSelector andReturn:(id)aValue times:(NSNumber *)times afterThatReturn:(id)aSecondValue;
  24. - (id)stub DEPRECATED_ATTRIBUTE;
  25. - (id)stubAndReturn:(id)aValue DEPRECATED_ATTRIBUTE;
  26. - (id)stubAndReturn:(id)aValue times:(id)times afterThatReturn:(id)aSecondValue DEPRECATED_ATTRIBUTE;
  27. // These methods will become private
  28. - (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern andReturn:(id)aValue;
  29. - (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern andReturn:(id)aValue overrideExisting:(BOOL)overrideExisting;
  30. - (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern andReturn:(id)aValue times:(id)times afterThatReturn:(id)aSecondValue;
  31. - (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern withBlock:(id (^)(NSArray *params))block;
  32. // These methods will become private
  33. + (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern andReturn:(id)aValue;
  34. + (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern andReturn:(id)aValue times:(id)times afterThatReturn:(id)aSecondValue;
  35. + (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern withBlock:(id (^)(NSArray *params))block;
  36. - (void)clearStubs;
  37. #pragma mark - Spying on Messages
  38. - (void)addMessageSpy:(id<KWMessageSpying>)aSpy forMessagePattern:(KWMessagePattern *)aMessagePattern;
  39. - (void)removeMessageSpy:(id<KWMessageSpying>)aSpy forMessagePattern:(KWMessagePattern *)aMessagePattern;
  40. - (KWCaptureSpy *)captureArgument:(SEL)selector atIndex:(NSUInteger)index;
  41. + (void)addMessageSpy:(id<KWMessageSpying>)aSpy forMessagePattern:(KWMessagePattern *)aMessagePattern;
  42. + (void)removeMessageSpy:(id<KWMessageSpying>)aSpy forMessagePattern:(KWMessagePattern *)aMessagePattern;
  43. + (KWCaptureSpy *)captureArgument:(SEL)selector atIndex:(NSUInteger)index;
  44. @end
  45. @interface NSObject(KiwiStubAdditions) <KiwiStubAdditions>
  46. @end