示例#1
0
        public void ShouldThrowOnPlayGameIfPlayerCountDenied([Values(0, 5)] int count)
        {
            var cds = new FakeDrawingService();
            var css = new FakeScoringService();
            var gps = new GamePlayingService(cds, css);

            var ex = Assert.Throws <ArgumentOutOfRangeException>(() => gps.PlayGame(count));

            Assert.That(ex.Message, Contains.Substring("Player count must be between 1 and 4."));
            // Note: Only 1 to 4 players allowed since wildcard and 4 hands leaves 0 cards.
        }
示例#2
0
        public void ShouldPlayGameIfPlayerCountAllowed4()
        {
            var cds = new FakeDrawingService();
            var css = new FakeScoringService();
            var gps = new GamePlayingService(cds, css);

            var gr = gps.PlayGame(4);

            Assert.That(gr.Wildcard, Is.Not.Null);
            Assert.That(gr.PlayerResults.Length, Is.EqualTo(4));

            var pr1 = gr.PlayerResults[0];

            Assert.That(pr1.Cards.Length, Is.EqualTo(5));
            Assert.That(pr1.Cards.Count(c => c.Kind == (int)Kinds.Ace), Is.EqualTo(1));
            Assert.That(pr1.Cards.Count(c => c.Suit == (int)Suits.Hearts), Is.EqualTo(5));
            Assert.That(pr1.Player, Is.EqualTo(1));
            Assert.That(pr1.Points, Is.EqualTo(2));

            var pr2 = gr.PlayerResults[1];

            Assert.That(pr2.Cards.Length, Is.EqualTo(5));
            Assert.That(pr2.Cards.Count(c => c.Kind == (int)Kinds.Ace), Is.EqualTo(1));
            Assert.That(pr2.Cards.Count(c => c.Suit == (int)Suits.Diamonds), Is.EqualTo(5));
            Assert.That(pr2.Player, Is.EqualTo(2));
            Assert.That(pr2.Points, Is.EqualTo(2));

            var pr3 = gr.PlayerResults[2];

            Assert.That(pr3.Cards.Length, Is.EqualTo(5));
            Assert.That(pr3.Cards.Count(c => c.Kind == (int)Kinds.Ace), Is.EqualTo(1));
            Assert.That(pr3.Cards.Count(c => c.Suit == (int)Suits.Clubs), Is.EqualTo(5));
            Assert.That(pr3.Player, Is.EqualTo(3));
            Assert.That(pr3.Points, Is.EqualTo(1));

            var pr4 = gr.PlayerResults[3];

            Assert.That(pr4.Cards.Length, Is.EqualTo(5));
            Assert.That(pr4.Cards.Count(c => c.Kind == (int)Kinds.Ace), Is.EqualTo(1));
            Assert.That(pr4.Cards.Count(c => c.Suit == (int)Suits.Spades), Is.EqualTo(5));
            Assert.That(pr4.Player, Is.EqualTo(4));
            Assert.That(pr4.Points, Is.EqualTo(1));
        }
示例#3
0
        public void ShouldPlayGameIfPlayerCountAllowed1()
        {
            var cds = new FakeDrawingService();
            var css = new FakeScoringService();
            var gps = new GamePlayingService(cds, css);

            var gr = gps.PlayGame(1);

            Assert.That(gr.Wildcard, Is.Not.Null);
            Assert.That(gr.Wildcard.Kind, Is.EqualTo((int)Kinds.Any));
            Assert.That(gr.Wildcard.Suit, Is.EqualTo((int)Suits.Any));
            Assert.That(gr.PlayerResults.Length, Is.EqualTo(1));

            var pr1 = gr.PlayerResults[0];

            Assert.That(pr1.Cards.Length, Is.EqualTo(5));
            Assert.That(pr1.Cards.Count(c => c.Kind == (int)Kinds.Ace), Is.EqualTo(1));
            Assert.That(pr1.Cards.Count(c => c.Suit == (int)Suits.Hearts), Is.EqualTo(5));
            Assert.That(pr1.Player, Is.EqualTo(1));
            Assert.That(pr1.Points, Is.EqualTo(2));
        }