public async Task AddBattleship_CellsNotAvailable_ShouldReturnBadRequest()
        {
            //Arrange
            var board = new Board(10);
            var ship  = new Battleship()
            {
                ShipId = 1, Size = 5, StartColumn = 0, StartRow = 0, IsHorizontalDirection = true
            };

            var redisServiceMock = new Mock <IRedisService>();

            redisServiceMock.Setup(r => r.Get <Board>(It.IsAny <string>())).ReturnsAsync(board);

            var helperServiceMock = new Mock <IGameHelperService>();

            helperServiceMock.Setup(r => r.AreCellsAvailable(It.IsAny <Board>(), It.IsAny <Battleship>())).Returns(false);

            var controller = new BoardGameController(redisServiceMock.Object, helperServiceMock.Object);

            //Act
            IActionResult result = await controller.AddBattleship(board.BoardId, ship);

            var badRequestResult = result as BadRequestObjectResult;

            //Asset
            Assert.IsNotNull(badRequestResult);
            Assert.AreEqual(400, badRequestResult.StatusCode);
            Assert.AreEqual("Selected position is not available on board " + board.BoardId.ToString(), badRequestResult.Value);
        }
        public async Task AddBattleship_InValidBoard_ShouldReturnBadRequest()
        {
            //Arrange
            var board = new Board(10);
            var ship  = new Battleship()
            {
                ShipId = 1, Size = 5, StartColumn = 0, StartRow = 0, IsHorizontalDirection = true
            };

            var redisServiceMock = new Mock <IRedisService>();

            redisServiceMock.Setup(r => r.Get <Board>(It.IsAny <string>())).ReturnsAsync(default(Board));

            var helperServiceMock = new Mock <IGameHelperService>();

            var controller = new BoardGameController(redisServiceMock.Object, helperServiceMock.Object);

            //Act
            IActionResult result = await controller.AddBattleship(board.BoardId, ship);

            var badRequestResult = result as BadRequestObjectResult;

            //Asset
            Assert.IsNotNull(badRequestResult);
            Assert.AreEqual(400, badRequestResult.StatusCode);
            Assert.AreEqual("Unable to get board for request " + board.BoardId.ToString(), badRequestResult.Value);
        }
        public async Task AddBattleship_InValidShip_ZeroSize_ShouldReturnBadRequest()
        {
            //Arrange
            var board = new Board(10);
            var ship  = new Battleship()
            {
                ShipId = 1, Size = 0, StartRow = 0, StartColumn = 0, IsHorizontalDirection = true
            };

            var redisServiceMock = new Mock <IRedisService>();

            var helperServiceMock = new Mock <IGameHelperService>();

            var controller = new BoardGameController(redisServiceMock.Object, helperServiceMock.Object);

            //Act
            IActionResult result = await controller.AddBattleship(board.BoardId, ship);

            var badRequestResult = result as BadRequestObjectResult;

            //Asset
            Assert.IsNotNull(result);
            Assert.AreEqual(400, badRequestResult.StatusCode);
            Assert.AreEqual("Cannot add ship of empty size", badRequestResult.Value);
        }
        public async Task AddBattleship_ValidShip_ShouldReturnOk()
        {
            //Arrange
            var board = new Board(10);
            var ship  = new Battleship()
            {
                ShipId = 1, Size = 5, StartColumn = 0, StartRow = 0, IsHorizontalDirection = true
            };

            var redisServiceMock = new Mock <IRedisService>();

            redisServiceMock.Setup(r => r.Get <Board>(It.IsAny <string>())).ReturnsAsync(board);
            redisServiceMock.Setup(r => r.Set <It.IsAnyType>(It.IsAny <string>(), It.IsAny <It.IsAnyType>())).ReturnsAsync(true);

            var helperServiceMock = new Mock <IGameHelperService>();

            helperServiceMock.Setup(r => r.AreCellsAvailable(It.IsAny <Board>(), It.IsAny <Battleship>())).Returns(true);
            helperServiceMock.Setup(r => r.AddBattleShip(It.IsAny <Board>(), It.IsAny <Battleship>())).Returns(true);

            var controller = new BoardGameController(redisServiceMock.Object, helperServiceMock.Object);

            //Act
            IActionResult result = await controller.AddBattleship(board.BoardId, ship);

            var okResult = result as OkObjectResult;

            //Asset
            Assert.IsNotNull(okResult);
            Assert.AreEqual(200, okResult.StatusCode);
        }
        public async Task AddBattleship_InValidShip_Null_ShouldReturnBadRequest()
        {
            //Arrange
            var        board = new Board(10);
            Battleship ship  = null;

            var redisServiceMock = new Mock <IRedisService>();

            var helperServiceMock = new Mock <IGameHelperService>();

            var controller = new BoardGameController(redisServiceMock.Object, helperServiceMock.Object);

            //Act
            IActionResult result = await controller.AddBattleship(board.BoardId, ship);

            var badRequestResult = result as BadRequestObjectResult;

            //Asset
            Assert.IsNotNull(badRequestResult);
            Assert.AreEqual(400, badRequestResult.StatusCode);
            Assert.AreEqual("Cannot add ship of empty size", badRequestResult.Value);
        }