Beispiel #1
0
        public void TestScore()
        {
            // ARRANGE
            IAxiom axiom = new Axiom();

            IList <ICard> cards = new List <ICard>
            {
                new Card(Colour.Blue, Number.Five, axiom),
                new Card(Colour.Red, Number.Seven, axiom),
                new Card(Colour.Red, Number.Six, axiom),
                new Card(Colour.Red, Number.Two, axiom),
                new Card(Colour.Green, Number.Seven, axiom),
                new Card(Colour.Blue, Number.Two, axiom),
            };

            IRule greenRule = new GreenRule(axiom);

            IPalette palette = new Palette(cards);

            // ACT
            IRuleScore ruleScore = greenRule.Score(palette);

            // ASSERT
            Assert.IsNotNull(ruleScore);
            Assert.AreEqual(expected: 3, actual: ruleScore.NumberOfCards);
            Assert.IsNotNull(ruleScore.TopCard);
            Assert.AreEqual(Colour.Red, ruleScore.TopCard.Colour);
            Assert.AreEqual(Number.Six, ruleScore.TopCard.Number);
        }
Beispiel #2
0
        public void TestConstructor()
        {
            // ARRANGE
            IAxiom axiom = new Axiom();

            // ACT
            IRule greenRule = new GreenRule(axiom);

            // ASSERT
            Assert.AreEqual("Most even cards wins", greenRule.Description);
            Assert.AreEqual(Colour.Green, greenRule.Colour);
        }
Beispiel #3
0
        public void TestScoringCards()
        {
            // ARRANGE
            IAxiom axiom = new Axiom();

            IList <ICard> cards = new List <ICard>
            {
                new Card(Colour.Blue, Number.Five, axiom),
                new Card(Colour.Red, Number.Seven, axiom),
                new Card(Colour.Red, Number.Six, axiom),
                new Card(Colour.Red, Number.Two, axiom),
                new Card(Colour.Green, Number.Seven, axiom),
                new Card(Colour.Blue, Number.Two, axiom)
            };

            IList <ICard> expectedScoringCards = new List <ICard>
            {
                new Card(Colour.Red, Number.Six, axiom),
                new Card(Colour.Red, Number.Two, axiom),
                new Card(Colour.Blue, Number.Two, axiom)
            };

            IRule greenRule = new GreenRule(axiom);

            IPalette palette = new Palette(cards);

            // ACT
            IList <ICard> scoringCards = greenRule.ScoringCards(palette);

            // ASSERT
            Assert.IsNotNull(scoringCards);
            Assert.AreEqual(expected: 3, scoringCards.Count);

            foreach (ICard card in expectedScoringCards)
            {
                Assert.IsTrue(scoringCards.Any(c => c.CompareTo(card) == 0), card.ToString());
            }
        }
Beispiel #4
0
        public void TestScoringCardsWithNoEvenCards()
        {
            // ARRANGE
            IAxiom axiom = new Axiom();

            IList <ICard> cards = new List <ICard>
            {
                new Card(Colour.Blue, Number.Five, axiom),
                new Card(Colour.Red, Number.Seven, axiom),
                new Card(Colour.Green, Number.Seven, axiom)
            };

            IRule greenRule = new GreenRule(axiom);

            IPalette palette = new Palette(cards);

            // ACT
            IList <ICard> scoringCards = greenRule.ScoringCards(palette);

            // ASSERT
            Assert.IsNotNull(scoringCards);
            Assert.AreEqual(expected: 0, scoringCards.Count);
        }