public void GetGameStatusReturnsAllPlayersWhoveJoined() { var player1 = new ApiPlayer("player1", "token", null); game.AddPlayer(player1); var gameStatus = game.GetGameStatus(); Assert.IsTrue(gameStatus.Players.Count() == 1); }
public IActionResult GameStatus() { GameStatus gameStatus; if (!memoryCache.TryGetValue("Status", out gameStatus)) { gameStatus = game.GetGameStatus(); if (gameStatus.GameState == GameState.Restarting) { game.StartJoining(); } MemoryCacheEntryOptions cacheEntryOptions = new MemoryCacheEntryOptions(); cacheEntryOptions.AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(1); memoryCache.Set("Status", gameStatus, cacheEntryOptions); } return(Ok(gameStatus)); }