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
def foundationComplete(self, suit=Suit.PIKES): self._foundations[suit] = FoundationBuilder().suit(suit).cards( 13).build() return self
def foundationEmpty(self, suit=Suit.PIKES): self._foundations[suit] = FoundationBuilder().build() return self
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))
def test_GivenemptyFoundation_whenAskEmpty_ReturnTrue(self): foundation = FoundationBuilder().build() self.assertTrue(foundation.isEmpty())
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))
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))
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))
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))
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)
def test_GivenAnotCompletePile_whenIsCompleteAsked_ReturnFalse(self): foundation = FoundationBuilder().cards(1).build() self.assertFalse(foundation.isComplete())
def test_GivenACompletePile_whenIsCompleteAsked_ReturnTrue(self): foundation = FoundationBuilder().cards(13).build() self.assertTrue(foundation.isComplete())