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 blueRule = new BlueRule();

            IPalette palette = new Palette(cards);

            // ACT
            IRuleScore ruleScore = blueRule.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.Seven, ruleScore.TopCard.Number);
        }
Beispiel #2
0
        public void TestConstructor()
        {
            // ACT
            IRule blueRule = new BlueRule();

            // ASSERT
            Assert.AreEqual("Most different colours wins", blueRule.Description);
            Assert.AreEqual(Colour.Blue, blueRule.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.Seven, axiom),
                new Card(Colour.Blue, Number.Five, axiom),
                new Card(Colour.Green, Number.Seven, axiom)
            };

            IRule blueRule = new BlueRule();

            IPalette palette = new Palette(cards);

            // ACT
            IList <ICard> scoringCards = blueRule.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());
            }
        }