コード例 #1
0
        public void DeckSizePersistedThroughTheGame()
        {
            var cardGameService = new CardGameService(_gameRules);

            while (!cardGameService.GameEnded)
            {
                cardGameService.DrawCard();
                cardGameService.CalculateDrawOutcome();
                Assert.Equal(_gameRules.DeckSize, cardGameService.Players.Sum(p => p.Total));
            }
        }
コード例 #2
0
        public void SecondPlayerWinTheGame()
        {
            var cardGameService = new CardGameService(_gameRules);

            cardGameService.Players[0].Deck = new Stack <int>(new int[] { 1, 2, 3, 4, 5, 6 });
            cardGameService.Players[1].Deck = new Stack <int>(new int[] { 1, 2, 10, 4, 5, 6 });

            while (!cardGameService.GameEnded)
            {
                cardGameService.DrawCard();
                cardGameService.CalculateDrawOutcome();
            }

            Assert.Equal(cardGameService.Players[1], cardGameService.Winner);
        }
コード例 #3
0
        public void FirstPlayerWin2Cards()
        {
            var cardGameService = new CardGameService(_gameRules);

            cardGameService.Players[0].Deck = new Stack <int>(new int[] { 1, 2, 3, 4, 10 });
            cardGameService.Players[1].Deck = new Stack <int>(new int[] { 1, 2, 3, 4, 5 });

            cardGameService.DrawCard();
            cardGameService.CalculateDrawOutcome();

            var expected = new List <int> {
                5, 10
            };

            Assert.Equal(expected, cardGameService.Players[0].Discard.OrderBy(x => x));
        }
コード例 #4
0
        public void FirstPlayerWin6Cards()
        {
            var cardGameService = new CardGameService(_gameRules);

            cardGameService.Players[0].Deck = new Stack <int>(new int[] { 1, 2, 3, 9, 5, 6 });
            cardGameService.Players[1].Deck = new Stack <int>(new int[] { 1, 2, 3, 4, 5, 6 });

            for (int i = 0; i < 3; i++)
            {
                cardGameService.DrawCard();
                cardGameService.CalculateDrawOutcome();
            }

            var expected = new List <int> {
                4, 5, 5, 6, 6, 9
            };

            Assert.Equal(expected, cardGameService.Players[0].Discard.OrderBy(x => x));
        }