Beispiel #1
0
        public void GamePutMustReturnGameStatus()
        {
            // Given
            Player player = new Player();
            BoringToeMoveResponse returnData = new BoringToeMoveResponse(player, gridMock.Object);

            returnData.GameOver = true;
            returnData.Repeat   = false;
            returnData.Winner   = player;

            serviceMock.Setup(m => m.PlayerMove(It.IsAny <long>(), It.IsAny <BoringToeMoveRequest>()))
            .Returns(returnData);
            BoringToeController controller = new BoringToeController(serviceMock.Object);

            // When
            OkObjectResult        resp     = controller.Put(100, new BoringToeMoveRequest()) as OkObjectResult;
            BoringToeMoveResponse respData = resp.Value as BoringToeMoveResponse;

            // Then
            Assert.IsInstanceOf <BoringToeMoveResponse>(resp.Value, "Value must be if type BoringToeMoveResponse");
            Assert.AreEqual(returnData.GameOver, respData.GameOver, "Responses GameOver flag must be mocked one");
            Assert.AreEqual(returnData.Repeat, respData.Repeat, "Responses Repeat flag must be mocked one");
            Assert.AreEqual(player, respData.Winner, "Responses Winner must be mocked player");
            Assert.AreEqual(player, respData.Player, "Responses Winner must be mocked player");
            serviceMock.Verify(v => v.PlayerMove(It.IsAny <long>(), It.IsAny <BoringToeMoveRequest>()), Times.Once, "Service's Player Move must be called 1 time");
        }
Beispiel #2
0
        public void GamePutMustReturnOk()
        {
            // Given
            Player player = new Player();
            BoringToeMoveResponse respData = new BoringToeMoveResponse(player, gridMock.Object);

            respData.GameOver = true;
            respData.Repeat   = false;
            respData.Winner   = player;

            serviceMock.Setup(m => m.PlayerMove(It.IsAny <long>(), It.IsAny <BoringToeMoveRequest>()))
            .Returns(respData);
            BoringToeController controller = new BoringToeController(serviceMock.Object);

            // When
            ActionResult resp = controller.Put(100, new BoringToeMoveRequest());

            // Then
            Assert.IsInstanceOf <OkObjectResult>(resp, "Value must be if type OkObjectResult");
        }