|
| 1 | +/* |
| 2 | + * Copyright (c) 2004-2014 Erik Doernenburg and contributors |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | + * not use these files except in compliance with the License. You may obtain |
| 6 | + * a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | + * License for the specific language governing permissions and limitations |
| 14 | + * under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +#import "OCMRecorder.h" |
| 18 | + |
| 19 | + |
| 20 | +@interface OCMStubRecorder : OCMRecorder |
| 21 | + |
| 22 | +- (id)andReturn:(id)anObject; |
| 23 | +- (id)andReturnValue:(NSValue *)aValue; |
| 24 | +- (id)andThrow:(NSException *)anException; |
| 25 | +- (id)andPost:(NSNotification *)aNotification; |
| 26 | +- (id)andCall:(SEL)selector onObject:(id)anObject; |
| 27 | +- (id)andDo:(void (^)(NSInvocation *invocation))block; |
| 28 | +- (id)andForwardToRealObject; |
| 29 | + |
| 30 | +@end |
| 31 | + |
| 32 | + |
| 33 | +@interface OCMStubRecorder (Properties) |
| 34 | + |
| 35 | +#define andReturn(aValue) _andReturn(({ __typeof__(aValue) _v = (aValue); [NSValue value:&_v withObjCType:@encode(__typeof__(_v))]; })) |
| 36 | +@property (nonatomic, readonly) OCMStubRecorder *(^ _andReturn)(NSValue *); |
| 37 | + |
| 38 | +#define andThrow(anException) _andThrow(anException) |
| 39 | +@property (nonatomic, readonly) OCMStubRecorder *(^ _andThrow)(NSException *); |
| 40 | + |
| 41 | +#define andPost(aNotification) _andPost(aNotification) |
| 42 | +@property (nonatomic, readonly) OCMStubRecorder *(^ _andPost)(NSNotification *); |
| 43 | + |
| 44 | +#define andCall(anObject, aSelector) _andCall(anObject, aSelector) |
| 45 | +@property (nonatomic, readonly) OCMStubRecorder *(^ _andCall)(id, SEL); |
| 46 | + |
| 47 | +#define andDo(aBlock) _andDo(aBlock) |
| 48 | +@property (nonatomic, readonly) OCMStubRecorder *(^ _andDo)(void (^)(NSInvocation *)); |
| 49 | + |
| 50 | +#define andForwardToRealObject() _andForwardToRealObject() |
| 51 | +@property (nonatomic, readonly) OCMStubRecorder *(^ _andForwardToRealObject)(void); |
| 52 | + |
| 53 | +@end |
| 54 | + |
| 55 | + |
| 56 | + |
0 commit comments