public void ProcessPlayerMovementReturnsOkResponseWithAGhostGameResponseDto()
        {
            Mock <IWordTreeManager> managerMock = new Mock <IWordTreeManager>();

            managerMock.Setup(x => x.GetNextMovement(TestWord))
            .Returns(new GhostGameResponseDto {
                GameStatus = GameStatus.Playing
            });

            GhostGameController controller   = new GhostGameController(managerMock.Object);
            IActionResult       actionResult = controller.ProcessPlayerMovement(new GhostGameRequestDto {
                CurrentWord = TestWord
            });

            ObjectResult objectResult = actionResult as OkObjectResult;

            Assert.IsNotNull(objectResult);

            GhostGameResponseDto content = objectResult.Value as GhostGameResponseDto;

            Assert.IsNotNull(content);

            Assert.AreEqual(GameStatus.Playing, content.GameStatus);
            Assert.AreEqual(200, objectResult.StatusCode);
        }
예제 #2
0
        public void GetNextMovementReturnsAPlayingMessageIfGameContinues()
        {
            WordTreeManager      manager  = new WordTreeManager(_providerMock, _configurationMock);
            GhostGameResponseDto response = manager.GetNextMovement("t");

            Assert.IsNotNull(response);
            Assert.AreEqual(GameStatus.Playing, response.GameStatus);
            Assert.IsFalse(string.IsNullOrEmpty(response.Message));
            Assert.IsFalse(string.IsNullOrEmpty(response.CurrentWord));
        }
예제 #3
0
        public void GetNextMovementReturnsAHumanWonMessageIfTheOnlyOptionLeftIsEndingAWord()
        {
            WordTreeManager      manager  = new WordTreeManager(_providerMock, _configurationMock);
            GhostGameResponseDto response = manager.GetNextMovement("w");

            Assert.IsNotNull(response);
            Assert.AreEqual(GameStatus.HumanPlayerWon, response.GameStatus);
            Assert.IsFalse(string.IsNullOrEmpty(response.Message));
            Assert.IsFalse(string.IsNullOrEmpty(response.CurrentWord));
        }
예제 #4
0
        public void GetNextMovementReturnsAComputerWonResponseIfWordDoesNotExist()
        {
            WordTreeManager      manager  = new WordTreeManager(_providerMock, _configurationMock);
            GhostGameResponseDto response = manager.GetNextMovement("x");

            Assert.IsNotNull(response);
            Assert.AreEqual(GameStatus.ComputerWon, response.GameStatus);
            Assert.IsFalse(string.IsNullOrEmpty(response.Message));
            Assert.IsFalse(string.IsNullOrEmpty(response.CurrentWord));
        }
예제 #5
0
        public void GetNextMovementReturnsAComputerWonResponseIfWordCompletesATreeBranch()
        {
            WordTreeManager manager = new WordTreeManager(_providerMock, _configurationMock);

            manager.LastSelectedNode = manager.GetCurrentNode("g");
            GhostGameResponseDto response = manager.GetNextMovement("go");

            Assert.IsNotNull(response);
            Assert.AreEqual(GameStatus.ComputerWon, response.GameStatus);
            Assert.IsFalse(string.IsNullOrEmpty(response.Message));
            Assert.IsFalse(string.IsNullOrEmpty(response.CurrentWord));
        }