def criteriaUsed(self): """ Test that the condition is false, if the criteria limits the matches below the required number """ name = "Test Name" cards = [BuildCard(name=name) for i in range(10)] event = CardsEvent(cards, None, BuildPlayerContext()) result = Matching(EVENT, criteria=FixedCriteria("name", name, "!=")).evaluate(event.context) self.assertFalse(result, "The Condition should be false, if the criteria limits the matching cards")
def isNotUnique(self): """ Test that a event without the specified unique field returns false """ playedSource = self.event.context.loadSource(PLAYED) playedSource.add(BuildCard(self.name)) result = Unique(self.field, PLAYED).evaluate(self.event.context) self.assertFalse( result, "When the Event card does have the specified field as unique, the condition should be false" )
def isUnique(self): """ Test that a event with the specified unique field returns true """ playedSource = self.event.context.loadSource(PLAYED) playedSource.add(BuildCard(self.name + "Gibberish")) result = Unique(self.field, PLAYED).evaluate(self.event.context) self.assertTrue( result, "When the Event card has the specified field as unique, the condition should be true" )
def isNotNthUnique(self): """ Test that the condition is false when the card is not the nth unique card played """ n = 2 playedSource = self.event.context.loadSource(PLAYED) [playedSource.add(BuildCard(self.name)) for i in range(n - 1)] result = NthUnique(n, []).evaluate(self.event.context) self.assertFalse( result, "When the Event card matches the criteria and is not the nth uniquely named card, the condition should be false" )
def isNthPlayed(self): """ Test that the condition is true when the card is the nth one played """ n = 3 playedSource = self.event.context.loadSource(PLAYED) [playedSource.add(BuildCard(self.name)) for i in range(n - 1)] result = NthPlayed(n, FixedCriteria("name", self.name, "==")).evaluate(self.event.context) self.assertTrue( result, "When the Event card matches the criteria and is the nth card, the condition should be true" )
class play(unittest.TestCase): """ Test cases of play """ def setUp(self): """ Build the Card for the test """ self.card = BuildCard(playEffects=[DummyEffect() for i in range(10)]) def playEffectsPerformed(self): """ Test that the card play effects were performed """ coroutine = self.card.play(BuildGame()) self.assertRaises(StopIteration, coroutine.next) self.assertTrue(all([effect.performed for effect in self.card.playEffects]), "All the effects should be performed")
class play(unittest.TestCase): """ Test cases of play """ def setUp(self): """ Build the Card for the test """ self.card = BuildCard(playEffects=[DummyEffect() for i in range(10)]) def playEffectsPerformed(self): """ Test that the card play effects were performed """ coroutine = self.card.play(BuildGame()) self.assertRaises(StopIteration, coroutine.next) self.assertTrue( all([effect.performed for effect in self.card.playEffects]), "All the effects should be performed")
def notMatchingCriteria(self): """ Test that the condition is false when the card is not the nth unique card played """ n = 3 type = self.cardType + "Gibberish" playedSource = self.event.context.loadSource(PLAYED) [ playedSource.add(BuildCard(self.name + str(i), cardType=type)) for i in range(n - 1) ] result = NthUnique(n, [FixedCriteria("cardType", type, "==")]).evaluate( self.event.context) self.assertFalse( result, "When the Event card does not match the criteria and is the nth uniquely named card, the condition should be false" )
def setUp(self): """ Build the Context for the test """ self.name = "Test Name" self.event = CardsEvent([BuildCard(self.name)], None, BuildPlayerContext())
def setUp(self): """ Build the Card for the test """ self.card = BuildCard(playEffects=[DummyEffect() for i in range(10)])
def invalid(self): """ Test that the comparison returns invalid """ cardToCompareAgainst = BuildCard(name=self.cardName+"Gibberish") isValid = self.criteria.compare(cardToCompareAgainst, self.context) self.assertFalse(isValid, "The Comparison should not be valid when the field value is set differently")
def valid(self): """ Test that the comparison can return valid if the cards in the zone are properly set """ cardToCompareAgainst = BuildCard(name=self.cardName) isValid = self.criteria.compare(cardToCompareAgainst, self.context) self.assertTrue(isValid, "The Comparison should be valid when the field value is set properly")
def setUp(self): """ Build the Zone and Criteria for the test """ self.cardName = "Blah Blah" cardsEvent = CardsEvent([BuildCard(name=self.cardName)], None, BuildPlayerContext()) self.context = cardsEvent.context self.criteria = ZoneCriteria("name", EVENT)
def setUp(self): """ Build the Card and Criteria for the test """ self.cardName = "Blah Blah" self.card = BuildCard(name=self.cardName)
def setUp(self): """ Build the Filter for the test """ self.cardName = "Blah Blah" self.cards = [BuildCard(name=self.cardName) for i in range(10)] cardsEvent = CardsEvent(self.cards, None, BuildPlayerContext()) self.context = cardsEvent.context
def setUp(self): """ Build the Event for the test """ self.name = "Test Name" self.cardType = "A Type" self.event = CardsEvent([BuildCard(self.name, cardType=self.cardType)], None, BuildPlayerContext())