Example #1
0
        public void PlayerRankingShouldContainTheNumberOfWins()
        {
            var round1 = new Round(1);
            round1.AddSelection(1, PaperStoneScissorsGameObject.Scissors);
            round1.AddSelection(2, PaperStoneScissorsGameObject.Paper);

            var round2 = new Round(2);
            round2.AddSelection(1, PaperStoneScissorsGameObject.Scissors);
            round2.AddSelection(2, PaperStoneScissorsGameObject.Paper);

            var round3 = new Round(3);
            round3.AddSelection(1, PaperStoneScissorsGameObject.Scissors);
            round3.AddSelection(2, PaperStoneScissorsGameObject.Paper);

            var players = HelperExtensions.GeneratePlayers(2);

            var game = new Game<Round>(players, new FirstToGamePlayingStrategy(3));

            game.AddRoundResult(round1);
            game.AddRoundResult(round2);
            game.AddRoundResult(round3);

            var ranking = game.GetRanking().ToList();

            Assert.That(ranking.Count, Is.EqualTo(2));
            Assert.That(ranking[0].Player.Wins, Is.EqualTo(3));
            Assert.That(ranking[1].Player.Wins, Is.EqualTo(0));
        }
Example #2
0
        public void GameShouldNotAllowAdditionalRoundsOnceComplete()
        {
            var round1 = new Round(1);
            round1.AddSelection(1, PaperStoneScissorsGameObject.Scissors);
            round1.AddSelection(2, PaperStoneScissorsGameObject.Paper);

            var round2 = new Round(2);
            round2.AddSelection(1, PaperStoneScissorsGameObject.Scissors);
            round2.AddSelection(2, PaperStoneScissorsGameObject.Paper);

            var players = HelperExtensions.GeneratePlayers(2);

            var game = new Game<Round>(players, new FirstToGamePlayingStrategy(1));

            game.AddRoundResult(round1);

            Assert.That(() => game.AddRoundResult(round2), Throws.An<GameAlreadyCompletedException>());
        }