public void GetNextNodeShouldReturnTheNextNodeToPlayWhenThereIsWinningOptions() { WordTreeManager manager = new WordTreeManager(_providerMock, _configurationMock); TreeNode nextNode = manager.GetNextNode(manager.GetCurrentNode("t")); Assert.IsNotNull(nextNode); }
public void GetMaximumLengthNodesReturnsAListOfNodesThatLeadToTheMaximumWordLength() { WordTreeManager manager = new WordTreeManager(_providerMock, _configurationMock); List <TreeNode> maximumLengthNodes = manager.GetMaximumLengthNodes(manager.GetCurrentNode("t")).ToList(); Assert.IsNotNull(maximumLengthNodes.Count == 2); }
public void GetWinningNodesShouldReturnAnEmptyListIfThereAreNoNodesThatLeadToVictory() { WordTreeManager manager = new WordTreeManager(_providerMock, _configurationMock); List <TreeNode> winningNodes = manager.GetWinningNodes(manager.GetCurrentNode("g")).ToList(); Assert.IsNotNull(winningNodes.Count == 0); }
public void GetCurrentNodeReturnsTheParentNodeForTheFirstCharacterIfLastProcessedIsNotDefined() { WordTreeManager manager = new WordTreeManager(_providerMock, _configurationMock); TreeNode currentNode = manager.GetCurrentNode(TestWord); Assert.IsNotNull(currentNode); Assert.AreEqual(TestWord.First(), currentNode.Value); Assert.IsTrue(currentNode.Children.Count == 3); Assert.IsFalse(currentNode.IsLeafNode); }
public void ResetGameSetsLastSelectedNodeToNull() { WordTreeManager manager = new WordTreeManager(_providerMock, _configurationMock); manager.LastSelectedNode = manager.GetCurrentNode("t"); bool reset = manager.ResetGame(); Assert.IsTrue(reset); Assert.IsNull(manager.LastSelectedNode); }
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)); }
public void GetCurrentNodeReturnsTheLastProcessedNodeChildrenIfLastProcessedIsDefined() { WordTreeManager manager = new WordTreeManager(_providerMock, _configurationMock) { LastSelectedNode = _dictionary['t'] }; TreeNode currentNode = manager.GetCurrentNode("te"); Assert.IsNotNull(currentNode); Assert.AreEqual('e', currentNode.Value); Assert.IsTrue(currentNode.Children.Count == 2); Assert.IsFalse(currentNode.IsLeafNode); }