-
-
Save lukeredpath/4459505 to your computer and use it in GitHub Desktop.
Quick preview of the new Mocky syntax. The previous syntax required passing an explicit builder object into the checking block. I tried to work around this with some macros to make it more readable but this seemed generally like a bad idea. The new version keeps macros to a minimum. I also felt the jMock syntax - verbatim - didn't feel quite rig…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)testCanExpectSingleMethodCallAndPass | |
{ | |
id<SomeProtocol> testObject = [context protocolMock:@protocol(SomeProtocol)]; | |
[context check:^{ | |
[[expectThat(testObject) receives] doSomething]; | |
}]; | |
[testObject doSomething]; | |
assertContextSatisfied(context); | |
} | |
- (void)testCanExpectSingleMethodSpecificNumberOfTimes | |
{ | |
id<SomeProtocol> testObject = [context protocolMock:@protocol(SomeProtocol)]; | |
[context check:^{ | |
[[expectThat(testObject) receivesExactly:3] doSomething]; | |
}]; | |
[testObject doSomething]; | |
[testObject doSomething]; | |
[testObject doSomething]; | |
assertContextSatisfied(context); | |
} | |
- (void)testCanExpectSingleMethodMaximumNumberOfTimes | |
{ | |
id<SomeProtocol> testObject = [context protocolMock:@protocol(SomeProtocol)]; | |
[context check:^{ | |
// the 'of' method is optional syntatic sugar | |
[[[expectThat(testObject) receivesAtMost:3] of] doSomething]; | |
}]; | |
[testObject doSomething]; | |
[testObject doSomething]; | |
[testObject doSomething]; | |
[testObject doSomething]; | |
assertContextSatisfied(context); // will fail! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment