Skip to content

Instantly share code, notes, and snippets.

@justinwyer
Created February 10, 2013 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinwyer/4750800 to your computer and use it in GitHub Desktop.
Save justinwyer/4750800 to your computer and use it in GitHub Desktop.
Example of mocking.
- (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