예제 #1
0
 def test_GivenAMove_WhenMoveFromEmptyPileToPile_ThenError(self):
     pileNumberOrigin = 1
     pileNumberDest = 7
     nCardsMoved = 1
     game = GameBuilder().pileEmpty(pileNumberOrigin).build()
     self.assertEqual(
         game.moveFromPileToPile(pileNumberOrigin, pileNumberDest, nCardsMoved),
         Error.EMPTY_PILE
     )
예제 #2
0
 def test_GivenAMoveThatFits_WhenMoveFromPileToPile_ThenCardOriginFlipped(self):
     pileNumberOrigin = 1
     pileNumberDest = 7
     nCardsMoved = 4
     game = GameBuilder().pileWithFaceUpCards(pileNumberOrigin).pileEmpty(pileNumberDest).build()
     cardsInPile = CardStackHelper.fromCardStack(game.getPiles()[pileNumberOrigin-1]).getCards()
     self.assertIsNone(game.moveFromPileToPile(pileNumberOrigin, pileNumberDest, nCardsMoved))
     cardsInPile[0].flip()
     self.assertEqual(game.getPiles()[pileNumberOrigin-1].getTop(), cardsInPile[0])
예제 #3
0
 def test_GivenAMove_WhenMoveFromPileToSamePile_ThenError(self):
     pileNumberOrigin = 1
     pileNumberDest = 1
     nCardsMoved = 1
     game = GameBuilder()\
            .pileWithFaceUpCards(pileNumberOrigin)\
            .cardInPile(pileNumberDest, CardBuilder().number(Number.ACE).faceUp().build()).build()
     self.assertEqual(
         game.moveFromPileToPile(pileNumberOrigin, pileNumberDest, nCardsMoved),
         Error.SAME_PILE
     )
예제 #4
0
 def test_GivenAMoveWithToManyCards_WhenMoveFromPileToPile_ThenError(self):
     pileNumberOrigin = 1
     pileNumberDest = 7
     nCardsMoved = 5
     game = GameBuilder()\
            .pileWithFaceUpCards(pileNumberOrigin)\
            .cardInPile(pileNumberDest, CardBuilder().number(Number.ACE).faceUp().build()).build()
     self.assertEqual(
         game.moveFromPileToPile(pileNumberOrigin, pileNumberDest, nCardsMoved),
         Error.NO_ENOUGH_CARDS_PILE
     )