public GameRunner CreateNewGame() { // Player chooses amount of players Game = new LudoGame() { Created = DateTime.Now }; Game.GamePlayers.Players = new List <GamePlayer>(); Game.Moves = new List <GameMove>(); Game.Status = "Created"; Game.GameName = InputDialogs.GetGameName(); int playerAmount = InputDialogs.GetPlayerAmount(); Game.GamePlayers.Players = InputDialogs.GetPlayers(playerAmount); int startingPlayerIndex = new Random().Next(0, Game.GamePlayers.Players.Count); Game.NextPlayer = Game.GamePlayers.Players[startingPlayerIndex]; Game.PieceSetup = Tools.GetGamePieceSetup(Game.GamePlayers.Players); Board.UpdateBoardBases(Game.PieceSetup); if (DbConnectionIsActive) { var db = new LudoGameDbContext(); SaveNewGameTask = new Task(() => SaveGameToDataBase(db)); SaveNewGameTask.Start(); } return(this); }
public void Given_Name_From_Input_Expect_Name_As_Output() { // Arrange var input = new StringReader("abc"); Console.SetIn(input); var output = new StringWriter(); Console.SetOut(output); var expectedOutput = $"Name The Game: \r\n"; // Act var result = InputDialogs.GetGameName(); // Assert Assert.AreEqual(expectedOutput, output.ToString()); Assert.AreEqual(result, "abc"); }