Objective-J Test API 0.1.0
|
00001 @import <Foundation/CPObject.j> 00002 00003 var wasntExpectingArguments = "Selector %@ wasn't expected to be called with arguments: %@!"; 00004 var wasntCalledEnough = "Selector %@ wasn't called enough times. Expected: %@ Got: %@"; 00005 var wasCalledTooMuch = "Selector %@ was called too many times. Expected: %@ Got: %@"; 00006 00007 @implementation OJMoqAssert : CPObject 00008 00009 + (void)selector:(SEL)selector hasBeenCalled:(int)times 00010 { 00011 var comparisonResult = [selector compareTimesCalled:times]; 00012 00013 if(comparisonResult === CPOrderedAscending) 00014 { 00015 [self fail:[CPString stringWithFormat:wasntCalledEnough, [selector name], 00016 times, [selector timesCalled]]]; 00017 } 00018 else if(comparisonResult === CPOrderedDescending) 00019 { 00020 [self fail:[CPString stringWithFormat:wasCalledTooMuch, [selector name], 00021 times, [selector timesCalled]]]; 00022 } 00023 } 00024 00025 + (void)fail:(CPString)message 00026 { 00027 [CPException raise:AssertionFailedError reason:message]; 00028 } 00029 00030 @end