public async Task MissedShotTest()
        {
            object expected = new GameStateResponse(1234)
            {
                GameStatus = GameStatuses.SHOOTING, NextPlayer = 1, Player2Ships = prepareTwoShipsWithOneDamage()
            };
            var mockCache = MockMemoryCacheServiceWithGetAndSet.GetMemoryCache(expected);

            var mockConfig = new Moq.Mock <IOptions <BattleshipConfiguration> >();

            mockConfig.Setup(config => config.Value).Returns(() => prepareConfig());
            var mockEngine = new Moq.Mock <GameEngine>(mockConfig.Object);
            var controller = new BattleShipController(mockCache, mockConfig.Object, mockEngine.Object, null);


            ShotRequest request = new ShotRequest()
            {
                GameId = 1234, PlayerId = 1, Coordinate = new Coordinate(5, 5)
            };

            var result     = controller.Shot(request);
            var viewResult = Assert.IsType <ActionResult <GameStateResponse> >(result);

            Assert.Equal(result.Value.NextPlayer, 2);                     //swapped players
            Assert.Equal(result.Value.GameStatus, GameStatuses.SHOOTING); //game still going
            Assert.Equal(result.Value.Message, "Missed!");                //message
        }
        public async Task ProperEndingShotShipDestroyedGameEndTest()
        {
            object expected = new GameStateResponse(1234)
            {
                GameStatus = GameStatuses.SHOOTING, NextPlayer = 1, Player2Ships = prepareTwoShipsWithOneMissingDamage()
            };
            var mockCache = MockMemoryCacheServiceWithGetAndSet.GetMemoryCache(expected);

            var mockConfig = new Moq.Mock <IOptions <BattleshipConfiguration> >();

            mockConfig.Setup(config => config.Value).Returns(() => prepareConfig());
            var mockEngine = new Moq.Mock <GameEngine>(mockConfig.Object);
            var controller = new BattleShipController(mockCache, mockConfig.Object, mockEngine.Object, null);


            ShotRequest request = new ShotRequest()
            {
                GameId = 1234, PlayerId = 1, Coordinate = new Coordinate(2, 2)
            };

            var result     = controller.Shot(request);
            var viewResult = Assert.IsType <ActionResult <GameStateResponse> >(result);

            Assert.Equal(result.Value.NextPlayer, 0);                                       //no more moves
            Assert.Equal(result.Value.GameStatus, GameStatuses.FINISHED);                   //Game finished
            Assert.Equal(result.Value.WinnerPlayer, 1);                                     //winner
            Assert.Equal(result.Value.Message, "Game finished, player 1 has won the game"); //message
        }
        public async Task ProperPlacementWaitingForSecondPlayerPlacingTest()
        {
            object expected  = new GameStateResponse(1234); //status = placing
            var    mockCache = MockMemoryCacheServiceWithGetAndSet.GetMemoryCache(expected);

            var mockConfig = new Moq.Mock <IOptions <BattleshipConfiguration> >();

            mockConfig.Setup(config => config.Value).Returns(() => prepareConfig());
            var mockEngine = new Moq.Mock <GameEngine>(mockConfig.Object);
            var controller = new BattleShipController(mockCache, mockConfig.Object, mockEngine.Object, null);

            List <ShipPlacement> correctShips = prepareValidShipsWithoutOne2Fielded();

            correctShips.Add(new ShipPlacement {
                Coordinates = new List <Coordinate> {
                    new Coordinate(8, 8), new Coordinate(9, 8)
                }
            });

            ShipPlacementRequest request = new ShipPlacementRequest()
            {
                GameId = 1234, PlayerId = 1, Ships = correctShips
            };

            var result     = controller.PlaceShips(request);
            var viewResult = Assert.IsType <ActionResult <GameStateResponse> >(result);
            GameStateResponse expectedNewGame = new GameStateResponse(1234);

            Assert.Equal(result.Value.NextPlayer, 0);                    //still waiting for second player to place ships
            Assert.Equal(result.Value.GameStatus, GameStatuses.PLACING); //still waiting for second player to place ships
            Assert.True(result.Value.Player1Ships.Count > 0);            //ships placed by first player
        }