Esempio n. 1
0
        public void TestDeleteBoard_BoardNotExist_ErrorResponse()
        {
            // Arrange
            var boardsManager        = new GameBoardsManager();
            var battleShipController = new BattleShipController(boardsManager);

            battleShipController.AddBoard();

            // Act
            var deleteBoardResult = battleShipController.DeleteBoard(new BoardRequest()
            {
                BoardId = "fake id",
            }) as JsonResult;

            // Arrange
            Assert.IsNotNull(deleteBoardResult);
            Assert.AreEqual(StatusCodes.Status400BadRequest, deleteBoardResult.StatusCode);
            var value = deleteBoardResult.Value as ErrorResponse;

            Assert.IsNotNull(value);
        }
Esempio n. 2
0
        public void TestDeleteBoard_Success()
        {
            // Arrange
            var boardsManager        = new GameBoardsManager();
            var battleShipController = new BattleShipController(boardsManager);
            var result  = battleShipController.AddBoard() as JsonResult;
            var boardId = (result.Value as BoardResponse).BoardId;

            // Act
            var deleteBoardResult = battleShipController.DeleteBoard(new BoardRequest()
            {
                BoardId = boardId,
            }) as JsonResult;

            // Arrange
            Assert.IsNotNull(deleteBoardResult);
            Assert.AreEqual(StatusCodes.Status200OK, deleteBoardResult.StatusCode);
            var value = deleteBoardResult.Value as SuccessResponse;

            Assert.IsNotNull(value);
        }