public async Task It_Creates_The_Game() { //--arrange var numberOfHumanPlayers = 2; var newGame = new NewGameRequest(TestUserName, numberOfHumanPlayers); //--act var result = await GamesClient.CreateGame(newGame, TestEnvironmentSettings.BaseApiUrl); //--assert result.NumberOfHumanPlayers.ShouldBe(newGame.NumberOfHumanPlayers); result.NumberOfAiPlayers.ShouldBe(newGame.NumberOfAiPlayers); result.GridSize.ShouldBe(50); result.Id.ShouldBeGreaterThan(0); result.Status.ShouldBe(GameStatus.NotStarted); result.GenerationNumber.ShouldBe(0); result.RoundNumber.ShouldBe(0); result.TotalDeadCells.ShouldBe(0); result.TotalRegeneratedCells.ShouldBe(0); result.TotalLiveCells.ShouldBe(0); result.EndOfGameCountDown.ShouldBeNull(); result.GrowthCycles.ShouldNotBeNull(); //--there should be no growth cycles if the game hasn't started result.GrowthCycles.Count.ShouldBe(0); result.StartingGameState.ShouldBeNull(); }
public async Task It_Automatically_Starts_The_Game_If_There_Is_Only_One_Human_Player() { //--arrange var numberOfHumanPlayers = 1; var numberOfAiPlayers = 1; var newGame = new NewGameRequest(TestUserName, numberOfHumanPlayers, numberOfAiPlayers); var totalNumberOfPlayers = numberOfHumanPlayers + numberOfAiPlayers; //--act var result = await GamesClient.CreateGame(newGame, TestEnvironmentSettings.BaseApiUrl); //--assert result.NumberOfHumanPlayers.ShouldBe(newGame.NumberOfHumanPlayers); result.NumberOfAiPlayers.ShouldBe(newGame.NumberOfAiPlayers); result.GridSize.ShouldBe(50); result.Id.ShouldBeGreaterThan(0); result.Status.ShouldBe(GameStatus.Started); result.RoundNumber.ShouldBe(1); result.TotalDeadCells.ShouldBe(0); result.TotalRegeneratedCells.ShouldBe(0); //--we start with 1 live cell per player result.TotalLiveCells.ShouldBe(totalNumberOfPlayers); //--there starting game state will be empty result.StartingGameState.ShouldNotBeNull(); result.StartingGameState.FungalCells.Count.ShouldBe(0); result.GrowthCycles.ShouldNotBeNull(); //--there should be a single growth cycle that places each player's starting cell result.GrowthCycles.Count.ShouldBe(1); var growthCycle = result.GrowthCycles[0]; //--every player will start with some mutation points to spend at the start of the game growthCycle.MutationPointsEarned.Count.ShouldBe(2); foreach (var keyValuePair in growthCycle.MutationPointsEarned) { keyValuePair.Value.ShouldBeGreaterThan(0); } //--there should be one toast change (i.e. new live cell placed) for each player growthCycle.ToastChanges.Count.ShouldBe(totalNumberOfPlayers); var maxCellIndex = result.NumberOfCells - 1; AssertToastChangeIsCorrect(growthCycle.ToastChanges[0], maxCellIndex); AssertToastChangeIsCorrect(growthCycle.ToastChanges[1], maxCellIndex); growthCycle.ToastChanges[0].Index.ShouldNotBe(growthCycle.ToastChanges[1].Index); result.Players.ShouldNotBeNull(); result.Players.Count.ShouldBe(totalNumberOfPlayers); var player = result.Players.First(x => x.Human); AssertHumanPlayerLooksRight(player); player.Name.ShouldBe(TestUserName); player.Status.ShouldBe("Joined"); player = result.Players.First(x => !x.Human); player.Id.ShouldNotBeNullOrEmpty(); player.Name.ShouldNotBeNull(); player.Status.ShouldBe("Joined"); }