Example #1
0
    def __init__(self):
        self._game = Game()
        self._foundations = {
            Suit.HEARTS: FoundationBuilder().suit(Suit.HEARTS).build(),
            Suit.DIAMONDS: FoundationBuilder().suit(Suit.DIAMONDS).build(),
            Suit.CLOVERS: FoundationBuilder().suit(Suit.CLOVERS).build(),
            Suit.PIKES: FoundationBuilder().suit(Suit.PIKES).build()
        }

        self._waste = None
        self._stock = None
Example #2
0
 def foundationComplete(self, suit=Suit.PIKES):
     self._foundations[suit] = FoundationBuilder().suit(suit).cards(
         13).build()
     return self
Example #3
0
 def foundationEmpty(self, suit=Suit.PIKES):
     self._foundations[suit] = FoundationBuilder().build()
     return self
Example #4
0
 def test_GivenNotemptyFoundation_whenCardFaceDownAskFitsIn_ReturnFalse(
         self):
     foundation = FoundationBuilder().suit(Suit.PIKES).cards(3).build()
     card = CardBuilder().suit(Suit.PIKES).number(Number.FOUR).build()
     self.assertFalse(foundation.isFittingIn(card))
Example #5
0
 def test_GivenemptyFoundation_whenAskEmpty_ReturnTrue(self):
     foundation = FoundationBuilder().build()
     self.assertTrue(foundation.isEmpty())
Example #6
0
 def test_GivenAemptyFoundation_whenNotAceAsksFitsIn_ReturnFalse(self):
     foundation = FoundationBuilder().suit(Suit.PIKES).build()
     card = CardBuilder().suit(Suit.PIKES).number(
         Number.TWO).faceUp().build()
     self.assertFalse(foundation.isFittingIn(card))
Example #7
0
 def test_GivenNotemptyFoundation_whenCardthatFitsAskFitsIn_ReturnTrue(
         self):
     foundation = FoundationBuilder().suit(Suit.PIKES).cards(3).build()
     card = CardBuilder().suit(Suit.PIKES).number(
         Number.FOUR).faceUp().build()
     self.assertTrue(foundation.isFittingIn(card))
Example #8
0
 def test_GivenAemptyFoundation_whenAceofOtherSuitAsksFitsIn_ReturnFalse(
         self):
     foundation = FoundationBuilder().suit(Suit.CLOVERS).build()
     card = CardBuilder().suit(Suit.PIKES).number(Number.ACE).build()
     self.assertFalse(foundation.isFittingIn(card))
Example #9
0
 def test_GivenAemptyFoundation_whenAceofSuitAsksFitsIn_ReturnTrue(self):
     foundation = FoundationBuilder().suit(Suit.PIKES).build()
     card = CardBuilder().suit(Suit.PIKES).number(
         Number.ACE).faceUp().build()
     self.assertTrue(foundation.isFittingIn(card))
Example #10
0
 def test_GivenAemptyFoundation_whenAceFaceDownaddToTop_ThenException(self):
     foundation = FoundationBuilder().suit(Suit.PIKES).build()
     card = CardBuilder().suit(Suit.PIKES).number(Number.ACE).build()
     with self.assertRaises(InvalidCard) as context:
         foundation.addToTop(card)
Example #11
0
 def test_GivenAnotCompletePile_whenIsCompleteAsked_ReturnFalse(self):
     foundation = FoundationBuilder().cards(1).build()
     self.assertFalse(foundation.isComplete())
Example #12
0
 def test_GivenACompletePile_whenIsCompleteAsked_ReturnTrue(self):
     foundation = FoundationBuilder().cards(13).build()
     self.assertTrue(foundation.isComplete())