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 )
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])
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 )
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 )