예제 #1
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])
예제 #2
0
 def test_GivenAGame_WhenMoveFromPileToFoundation_ThenCardIsMoved(self):
     pileNumber = 1
     cardToMove = CardBuilder().suit(Suit.PIKES).number(Number.ACE).faceUp().build()
     game = GameBuilder()\
            .cardInPile(pileNumber, CardBuilder().faceUp().build())\
            .cardInPile(pileNumber, cardToMove)\
            .build()
     self.assertIsNone(game.moveFromPileToFoundation(pileNumber, Suit.PIKES))
     self.assertNotEqual(game.getPiles()[pileNumber-1].getTop(), cardToMove)
     self.assertEqual(game.getFoundations()[Suit.PIKES].getTop(), cardToMove)
     self.assertTrue(game.getPiles()[pileNumber-1].getTop().isFaceUp())        
예제 #3
0
 def test_GivenAGame_WhenMoveFromWasteToPile_ThenCardIsMoved(self):
     pileNumber = 1
     cardToMove = CardBuilder().suit(Suit.PIKES).number(Number.ACE).faceUp().build()
     cardInPile = CardBuilder().suit(Suit.HEARTS).number(Number.TWO).faceUp().build()
     game = GameBuilder().cardInWaste(cardToMove).cardInPile(pileNumber, cardInPile).build()
     self.assertIsNone(game.moveFromWasteToPile(pileNumber))
     self.assertTrue(game.getWaste().isEmpty())
     self.assertEqual(game.getPiles()[pileNumber-1].getTop(), cardToMove)
예제 #4
0
 def test_GivenAGame_WhenMoveFromFoundationToPile_ThenCardIsMoved(self):
     pileNumber = 1
     cardToMove = CardBuilder().suit(Suit.PIKES).number(Number.KING).faceUp().build()
     cardLeft = CardBuilder().suit(Suit.PIKES).number(Number.QUEEN).faceUp().build()
     game = GameBuilder().pileEmpty(pileNumber).foundationComplete(Suit.PIKES).build()
     self.assertIsNone(game.moveFromFoundationToPile(Suit.PIKES, pileNumber))
     self.assertEqual(game.getPiles()[pileNumber-1].getTop(), cardToMove)
     self.assertEqual(game.getFoundations()[Suit.PIKES].getTop(), cardLeft)