के साथ एक बूल लौटाता है जो एक विधि को दबाता है मैं ओसीएमॉक 1.70 का उपयोग कर रहा हूं और मुझे एक साधारण विधि का मज़ाक उड़ाते हुए समस्या है जो एक बूल मान देता है। यहां मेरा कोड है:ओसीएमॉक
@interface MyClass : NSObject
- (void)methodWithArg:(id)arg;
- (BOOL)methodWithBOOLResult;
@end
@implementation MyClass
- (void)methodWithArg:(id)arg {
NSLog(@"methodWithArg: %@", arg);
}
- (BOOL)methodWithBOOLResult {
NSLog(@"methodWithBOOLResult");
return YES;
}
@end
- (void)testMock {
id real = [[[MyClass alloc] init] autorelease];
[real methodWithArg:@"foo"];
//=> SUCCESS: logs "methodWithArg: foo"
id mock = [OCMockObject mockForClass:[MyClass class]];
[[mock stub] methodWithArg:[OCMArg any]];
[mock methodWithArg:@"foo"];
//=> SUCCESS: "nothing" happens
NSAssert([real methodWithBOOLResult], nil);
//=> SUCCESS: logs "methodWithBOOLResult", YES returned
BOOL boolResult = YES;
[[[mock stub] andReturn:OCMOCK_VALUE(boolResult)] methodWithBOOLResult];
NSAssert([mock methodWithBOOLResult], nil);
//=> FAILURE: raises an NSInvalidArgumentException:
// Expected invocation with object return type.
}
मैं क्या गलत कर रहा हूं? - विशेष रूप से NSNumber
andReturnValue:
स्वीकार करता किसी भीNSValue
:
ओसीएमॉक के नए संस्करणों को ओसीएमओकेके_वीएमएल को स्थिरांक पर भी काम करना चाहिए; '' OCMOCK_VALUE (NO) '' ',' '' NO''', और '' '(NO)' '' सभी को काम करना चाहिए। –