public PointList WriteSolvedPuzzleCoordinatesToConsole(string searchString, IGridManager gridManager) { string[] searchWords = searchString.Split(','); PointList points = new PointList(); _wordFinder.SetSearchOrientations(_searchOrientationManager.GetSearchOrientations(gridManager)); foreach (var searchWord in searchWords) { var coordinatesOfSearchTarget = _wordFinder.GetCoordinatesOfSearchTarget(searchWord, $"Did not find {searchWord} in puzzle."); if (coordinatesOfSearchTarget != null && coordinatesOfSearchTarget.Count > 0) { _consoleWrapper.WriteLine($"{searchWord}: " + $"{coordinatesOfSearchTarget.ToString()}"); //create list of all coordinates of grid that are part of the puzzle solution foreach (var coordinate in coordinatesOfSearchTarget) { if (!points.Contains(coordinate)) { points.Add(coordinate); } } } } return(points.Count > 0 ? points : null); }
public void GetCoordinatesOfSearchTarget_NxNGridContainsTargetInLeftRightOrientation_CoordinatesReturned(string gridSource, string searchTarget, string expected) { //arrange IGridManager gridManager = new GridManager(_testUtilities.StringToGrid(gridSource)); //act IWordFinder wordFinder = new WordFinder(_searchOrientationManager.GetSearchOrientations(gridManager)); string actual = (wordFinder.GetCoordinatesOfSearchTarget(searchTarget)).ToString(); //assert Assert.Equal(expected, actual); }