private Dictionary <String, List <Vector2> > FindAllWordLocations(WordSearchPuzzle puzzle) { DirectionSearchFactory directionSearchFactory = new DirectionSearchFactory(puzzle); WordSearchAlgorithm algorithm = new WordSearchAlgorithm(directionSearchFactory, puzzle.WordsList); return(algorithm.SearchEachWord()); }
public void Given4x4WordPuzzleWithoutWordsWhenCallingSearchEachWordThenSearchEachWordReturnsEmptyDictionary(WordSearchPuzzle puzzle) { DirectionSearchFactory directionSearchFactory = new DirectionSearchFactory(puzzle); sut = new WordSearchAlgorithm(directionSearchFactory, puzzle.WordsList); Dictionary <String, List <Vector2> > result = sut.SearchEachWord(); Assert.IsEmpty(result); }
public void Given4x4WordWithOneUpWordsPuzzleWhenCallingSearchEachWordsThenSearchEachWordReturnsAStringVector2DictionaryWithEntryForKIRK(WordSearchPuzzle puzzle, Dictionary <String, List <Vector2> > expected) { DirectionSearchFactory directionSearchFactory = new DirectionSearchFactory(puzzle); sut = new WordSearchAlgorithm(directionSearchFactory, puzzle.WordsList); Dictionary <String, List <Vector2> > result = sut.SearchEachWord(); Assert.AreEqual(expected, result); }
public void Given4x4WordPuzzleWithWordNotInPuzzleWhenCallingSearchEachWordsThenSearchEachWordLicationsThrowsNoException(WordSearchPuzzle puzzle) { puzzle.AddWord("UHURA"); DirectionSearchFactory directionSearchFactory = new DirectionSearchFactory(puzzle); sut = new WordSearchAlgorithm(directionSearchFactory, puzzle.WordsList); sut.SearchEachWord(); }
public void Given4x4WordWithTwoWordsPuzzleWhenCallingSearchEachWordsThenSearchEachWordReturnsAStringListVector2Dictionary(WordSearchPuzzle puzzle) { DirectionSearchFactory directionSearchFactory = new DirectionSearchFactory(puzzle); sut = new WordSearchAlgorithm(directionSearchFactory, puzzle.WordsList); Dictionary <String, List <Vector2> > result = sut.SearchEachWord(); Assert.IsInstanceOf(typeof(Dictionary <String, List <Vector2> >), result); }
public void GivenValid4x4WordPuzzleWhenCallingSearchEachWordThenSearchEachWordReturnsAllWordsLocations(WordSearchPuzzle puzzle, Dictionary <String, List <Vector2> > expected) { DirectionSearchFactory directionSearchFactory = new DirectionSearchFactory(puzzle); sut = new WordSearchAlgorithm(directionSearchFactory, puzzle.WordsList); sut.SearchEachWord(); Dictionary <String, List <Vector2> > result = sut.SearchEachWord(); Assert.AreEqual(expected, result); }
public void Given4x4WordPuzzleWith2WordsOneOfWhichIsNotInThePuzzleWhenCallingSearchEachWordsThenSearchEachWordLicationsReturnsAnEmptyDictionary(WordSearchPuzzle puzzle) { puzzle.AddWord("KHAN"); DirectionSearchFactory directionSearchFactory = new DirectionSearchFactory(puzzle); sut = new WordSearchAlgorithm(directionSearchFactory, puzzle.WordsList); Dictionary <String, List <Vector2> > result = sut.SearchEachWord(); Dictionary <String, List <Vector2> > expected = new Dictionary <string, List <Vector2> >(); Assert.AreEqual(expected, result); }
public void Given4x4WordPuzzleWithoutWordsWhenCallingSearchEachWordAddingAWordThenCallingSearchEachWordAgainReturnsDictionaryWithElements(WordSearchPuzzle puzzle) { DirectionSearchFactory directionSearchFactory = new DirectionSearchFactory(puzzle); sut = new WordSearchAlgorithm(directionSearchFactory, puzzle.WordsList); sut.SearchEachWord(); puzzle.AddWord("KIRK"); Dictionary <String, List <Vector2> > result = sut.SearchEachWord(); Assert.IsNotEmpty(result); }
public void GivenInvalid4x4WordPuzzleWhenCallingSearchEachWordTwiceThenSecondSearchEachWordReturnsEmptyDictionary(WordSearchPuzzle puzzle) { puzzle.AddWord("UHURA"); DirectionSearchFactory directionSearchFactory = new DirectionSearchFactory(puzzle); sut = new WordSearchAlgorithm(directionSearchFactory, puzzle.WordsList); sut.SearchEachWord(); Dictionary <String, List <Vector2> > result = sut.SearchEachWord(); Assert.IsEmpty(result); }
public void Given4x4WordWithTwoDownRightWordsPuzzleWhenCallingSearchEachWordsThenSearchEachWordReturnsAStringVector2DictionaryWithEntryForKIRK(WordSearchPuzzle puzzle, Dictionary <String, List <Vector2> > expected) { puzzle.AddWord("HAN"); DirectionSearchFactory directionSearchFactory = new DirectionSearchFactory(puzzle); sut = new WordSearchAlgorithm(directionSearchFactory, puzzle.WordsList); Dictionary <String, List <Vector2> > result = sut.SearchEachWord(); List <Vector2> hanLocation = new List <Vector2>(); hanLocation.Add(new Vector2(0, 1)); hanLocation.Add(new Vector2(1, 2)); hanLocation.Add(new Vector2(2, 3)); expected.Add("HAN", hanLocation); Assert.AreEqual(expected, result); }
public WordSearchAlgorithm(DirectionSearchFactory directionSearchFactory, List <String> wordsList) { directionSearchStrategies = directionSearchFactory.CreateStrategies(); words = wordsList; }
public void init() { WordSearchPuzzle puzzle = new WordSearchPuzzle(); sut = new DirectionSearchFactory(puzzle); }