Created
February 10, 2013 19:49
-
-
Save justinwyer/4750800 to your computer and use it in GitHub Desktop.
Example of mocking.
This file contains 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)testShouldKnowCardsCanBeAddedToDeck { | |
Deck *deck = [Deck new]; | |
Card *card = [[Card alloc] initWithContents:@"Test Card"]; | |
id cardsMock = [OCMockObject mockForClass:[NSMutableArray class]]; | |
[[cardsMock expect] addObject:card]; | |
deck.cards = cardsMock; | |
[deck addCard:card atTop:NO]; | |
[cardsMock verify]; | |
} | |
- (void)testShouldKnowCardsCanBeAddedToTopOfDeck { | |
Deck *deck = [Deck new]; | |
Card *card = [[Card alloc] initWithContents:@"Test Card"]; | |
id cardsMock = [OCMockObject mockForClass:[NSMutableArray class]]; | |
[[cardsMock expect] insertObject:card atIndex:0]; | |
deck.cards = cardsMock; | |
[deck addCard:card atTop:YES]; | |
[cardsMock verify]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment