public void GameDoesNotPermitAddMoreThanOnePlayerWithSameName() { var stickGame = new StickGame(); Assert.Throws <InvalidOperationException>(() => { stickGame.AddPlayer(new Player("mario")); stickGame.AddPlayer(new Player("mario")); } ); }
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); }
public void PlayerIsPresentInPlayersListWhenWasAddedBefore() { var stickGame = new StickGame(); stickGame.AddPlayer(new Player("mario")); stickGame.Players.First(a => a.Name == "mario"); }
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; } } } }
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); }
private static void AddDefaultPlayers(StickGame stickGame) { stickGame.AddPlayer(new Player("mario")); stickGame.AddPlayer(new Player("pc")); }