Пример #1
0
        public void GameDoesNotPermitAddMoreThanOnePlayerWithSameName()
        {
            var stickGame = new StickGame();

            Assert.Throws <InvalidOperationException>(() =>
            {
                stickGame.AddPlayer(new Player("mario"));
                stickGame.AddPlayer(new Player("mario"));
            }
                                                      );
        }
Пример #2
0
        public void GameControlTurnsPlayerShouldPlayOnceByGame_ThrowsInvalidOperationExceptionWhenPlayerPlaysInWrongMoment()
        {
            var stickGame = new StickGame();

            stickGame.AddPlayer(new Player("mario"));
            stickGame.AddPlayer(new Player("pc"));
            stickGame.AddPlayer(new Player("maria"));
            stickGame.AddPlayer(new Player("anacleto"));
            stickGame.AddPlayer(new Player("malu"));

            TestDelegate assert = () => stickGame.RemoveSticks("anacleto", 1);

            Assert.Throws <InvalidOperationException>(assert);
        }
Пример #3
0
        public void PlayerIsPresentInPlayersListWhenWasAddedBefore()
        {
            var stickGame = new StickGame();

            stickGame.AddPlayer(new Player("mario"));
            stickGame.Players.First(a => a.Name == "mario");
        }
Пример #4
0
        private static void CreatePlayersStep(int cont, StickGame stickGame)
        {
            while (true)
            {
                Console.WriteLine($"\nPlayer {cont}");
                Console.Write($"Name:");
                var userInput = Console.ReadLine();
                if (!string.IsNullOrEmpty(userInput.Trim()))
                {
                    stickGame.AddPlayer(new Player(userInput));
                    cont++;
                }
                else
                {
                    Console.WriteLine($"Name cannot be empty or white space!");
                    continue;
                }

                while (userInput != "y" && userInput != "n")
                {
                    Console.WriteLine($"\nDo you want add one more player? (y to yes - n to no)");
                    userInput = Console.ReadLine();
                    if (userInput == "y")
                    {
                        continue;
                    }
                    if (userInput == "n")
                    {
                        return;
                    }
                }
            }
        }
Пример #5
0
        public void GameDoesNotAllowAddMorePlayersThanSticks()
        {
            var          stickGame     = new StickGame();
            const int    TOTAL_STICKS  = StickGame.TOTAL_STICKS;
            var          stickersCount = new int[TOTAL_STICKS].ToList();
            TestDelegate code          = () => { stickersCount.ForEach((i) => stickGame.AddPlayer(new Player($"player{i}"))); };

            Assert.Throws <InvalidOperationException>(code);
        }
Пример #6
0
 private static void AddDefaultPlayers(StickGame stickGame)
 {
     stickGame.AddPlayer(new Player("mario"));
     stickGame.AddPlayer(new Player("pc"));
 }