Skip to content

Instantly share code, notes, and snippets.

@johncalvinyoung
Created July 26, 2012 19:29
Show Gist options
  • Save johncalvinyoung/3184022 to your computer and use it in GitHub Desktop.
Save johncalvinyoung/3184022 to your computer and use it in GitHub Desktop.
Testing End Conditions for a game of Go Fish
- (void)testEndConditionsDeck {
RMSGoFishGame *game = [RMSGoFishGame new];
[game deal];
RMSGoFishPlayer *player1 = [game.players objectAtIndex:(NSUInteger)0];
RMSGoFishPlayer *player2 = [game.players objectAtIndex:(NSUInteger)1];
RMSGoFishPlayer *player3 = [game.players objectAtIndex:(NSUInteger)2];
RMSGoFishPlayer *player4 = [game.players objectAtIndex:(NSUInteger)3];
game.deck.cards = [NSMutableArray new];
[game gameLoop];
STAssertEquals(player1.hand.count, (NSUInteger)5,@"Player 1 played after the game was over!");
STAssertEquals(player2.hand.count, (NSUInteger)5,@"Player 2 played after the game was over!");
STAssertEquals(player3.hand.count, (NSUInteger)5,@"Player 3 played after the game was over!");
STAssertEquals(player4.hand.count, (NSUInteger)5,@"Player 4 played after the game was over!");
}
- (void)testEndConditionsPlayer {
RMSGoFishGame *game = [RMSGoFishGame new];
[game deal];
RMSGoFishPlayer *player1 = [game.players objectAtIndex:(NSUInteger)0];
RMSGoFishPlayer *player2 = [game.players objectAtIndex:(NSUInteger)1];
RMSGoFishPlayer *player3 = [game.players objectAtIndex:(NSUInteger)2];
RMSGoFishPlayer *player4 = [game.players objectAtIndex:(NSUInteger)3];
[player4 emptyHand];
game.deck.cards = [NSMutableArray new];
[game gameLoop];
STAssertEquals(player1.hand.count, (NSUInteger)5,@"Player 1 played after the game was over!");
STAssertEquals(player2.hand.count, (NSUInteger)5,@"Player 2 played after the game was over!");
STAssertEquals(player3.hand.count, (NSUInteger)5,@"Player 3 played after the game was over!");
STAssertEquals(player4.hand.count, (NSUInteger)0,@"Player 4 played after the game was over!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment