main
1//
2// Licensed under the terms in License.txt
3//
4// Copyright 2010 Allen Ding. All rights reserved.
5//
6
7#import "KiwiConfiguration.h"
8#import "KWInvocationCapturer.h"
9
10@class KWMessagePattern;
11@class KWCaptureSpy;
12
13@protocol KWMessageSpying;
14@protocol KWVerifying;
15
16@interface KWMock : NSObject {
17@private
18 BOOL isPartialMock;
19 BOOL isNullMock;
20 NSString *mockName;
21 id mockedObject;
22 Class mockedClass;
23 Protocol *mockedProtocol;
24 NSMutableArray *stubs;
25 NSMutableArray *expectedMessagePatterns;
26 NSMutableDictionary *messageSpies;
27}
28
29#pragma mark -
30#pragma mark Initializing
31
32- (id)initForClass:(Class)aClass;
33- (id)initForProtocol:(Protocol *)aProtocol;
34- (id)initWithName:(NSString *)aName forClass:(Class)aClass;
35- (id)initWithName:(NSString *)aName forProtocol:(Protocol *)aProtocol;
36
37- (id)initAsNullMockForClass:(Class)aClass;
38- (id)initAsNullMockForProtocol:(Protocol *)aProtocol;
39- (id)initAsNullMockWithName:(NSString *)aName forClass:(Class)aClass;
40- (id)initAsNullMockWithName:(NSString *)aName forProtocol:(Protocol *)aProtocol;
41
42- (id)initAsPartialMockForObject:(id)object;
43- (id)initAsPartialMockWithName:(NSString *)aName forObject:(id)object;
44
45+ (id)mockForClass:(Class)aClass;
46+ (id)mockForProtocol:(Protocol *)aProtocol;
47+ (id)mockWithName:(NSString *)aName forClass:(Class)aClass;
48+ (id)mockWithName:(NSString *)aName forProtocol:(Protocol *)aProtocol;
49
50+ (id)nullMockForClass:(Class)aClass;
51+ (id)nullMockForProtocol:(Protocol *)aProtocol;
52+ (id)nullMockWithName:(NSString *)aName forClass:(Class)aClass ;
53+ (id)nullMockWithName:(NSString *)aName forProtocol:(Protocol *)aProtocol;
54
55+ (id)partialMockForObject:(id)object;
56+ (id)partialMockWithName:(NSString *)aName forObject:(id)object;
57
58#pragma mark -
59#pragma mark Properties
60
61@property (nonatomic, readonly) BOOL isNullMock;
62@property (nonatomic, readonly) BOOL isPartialMock;
63@property (nonatomic, readonly) NSString *mockName;
64@property (nonatomic, readonly) Class mockedClass;
65@property (nonatomic, readonly) id mockedObject;
66@property (nonatomic, readonly) Protocol *mockedProtocol;
67
68#pragma mark -
69#pragma mark Stubbing Methods
70
71- (void)stub:(SEL)aSelector;
72- (void)stub:(SEL)aSelector withBlock:(id (^)(NSArray *params))block;
73- (void)stub:(SEL)aSelector withArguments:(id)firstArgument, ...;
74- (void)stub:(SEL)aSelector andReturn:(id)aValue;
75- (void)stub:(SEL)aSelector andReturn:(id)aValue withArguments:(id)firstArgument, ...;
76
77- (id)stub;
78- (id)stubAndReturn:(id)aValue;
79- (id)stubAndReturn:(id)aValue times:(id)times afterThatReturn:(id)aSecondValue;
80
81- (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern andReturn:(id)aValue;
82- (void)stubMessagePattern:(KWMessagePattern *)aMessagePattern andReturn:(id)aValue times:(id)times afterThatReturn:(id)aSecondValue;
83
84- (void)clearStubs;
85
86#pragma mark -
87#pragma mark Spying on Messages
88
89- (void)addMessageSpy:(id<KWMessageSpying>)aSpy forMessagePattern:(KWMessagePattern *)aMessagePattern;
90- (void)removeMessageSpy:(id<KWMessageSpying>)aSpy forMessagePattern:(KWMessagePattern *)aMessagePattern;
91
92
93#pragma mark -
94#pragma mark Expecting Messages
95
96- (void)expect:(SEL)aSelector;
97- (void)expect:(SEL)aSelector withArguments:(id)firstArgument, ...;
98
99- (id)expect;
100
101- (void)expectMessagePattern:(KWMessagePattern *)aMessagePattern;
102
103@end