public void GivenAValidStringFileNameContainingAValidWordPuzzleWhenPassedIntoParseFileToWordSearchPuzzleThenResultingWordSearchPuzzleGetWordsListHasTheSolution(Dictionary <String, List <Vector2> > expected) { WordSearchPuzzle puzzle = sut.ParseFileToWordSearchPuzzle(testPuzzlePath + "Example15x15.txt"); WordsLocationFinder wordsFinder = new WordsLocationFinder(puzzle); WordsMapDecorator result = wordsFinder.GetWordsMap(); Assert.AreEqual(expected, result); }
public void GivenAValidStringFileNameContaingAPuzzleWithOneWordWhenPassedToParseFileToWordSearchPuzzleThenResultingWordSearchPuzzleGetWordsLocationHasTheSolution() { WordSearchPuzzle puzzle = sut.ParseFileToWordSearchPuzzle(testPuzzlePath + "oneWord4x4.txt"); WordsLocationFinder wordsFinder = new WordsLocationFinder(puzzle); Dictionary <String, List <Vector2> > result = wordsFinder.GetWordsMap(); List <Vector2> kirkLocation = new List <Vector2>(); kirkLocation.Add(new Vector2(3, 0)); kirkLocation.Add(new Vector2(2, 0)); kirkLocation.Add(new Vector2(1, 0)); kirkLocation.Add(new Vector2(0, 0)); Dictionary <String, List <Vector2> > wordsLocation = new Dictionary <String, List <Vector2> >(); wordsLocation.Add("KIRK", kirkLocation); WordsMapDecorator expected = new WordsMapDecorator(wordsLocation); Assert.AreEqual(expected, result); }
private WordSearchPuzzle KIRKUpInFirstColumnPuzzle() { WordSearchPuzzle puzzle = new WordSearchPuzzle(); puzzle.AddWord("KIRK"); puzzle.AddLetterAt('K', 0, 0); puzzle.AddLetterAt('E', 1, 0); puzzle.AddLetterAt('F', 2, 0); puzzle.AddLetterAt('N', 3, 0); puzzle.AddLetterAt('R', 0, 1); puzzle.AddLetterAt('R', 1, 1); puzzle.AddLetterAt('J', 2, 1); puzzle.AddLetterAt('A', 3, 1); puzzle.AddLetterAt('I', 0, 2); puzzle.AddLetterAt('L', 1, 2); puzzle.AddLetterAt('I', 2, 2); puzzle.AddLetterAt('H', 3, 2); puzzle.AddLetterAt('K', 0, 3); puzzle.AddLetterAt('D', 1, 3); puzzle.AddLetterAt('J', 2, 3); puzzle.AddLetterAt('M', 3, 3); return(puzzle); }
public void Given4x4WordSearchPuzzleWhenFirstRowLocationListToGetStringFromLocationsThenGetStringFromLocationsDoesNotReturnNull(WordSearchPuzzle puzzle) { IDirectionSearchStrategy sut = CreateInstance(puzzle); List <Vector2> firstRow = new List <Vector2>(); firstRow.Add(new Vector2(0, 0)); firstRow.Add(new Vector2(1, 0)); firstRow.Add(new Vector2(2, 0)); firstRow.Add(new Vector2(3, 0)); String result = sut.GetStringFromLocations(firstRow); Assert.IsNotNull(result); }
public DirectionSearchFactory(WordSearchPuzzle wordSearchPuzzle) { puzzle = wordSearchPuzzle; }
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 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 init() { sut = new WordSearchPuzzle(); }
public void init() { WordSearchPuzzle puzzle = new WordSearchPuzzle(); sut = new DirectionSearchFactory(puzzle); }
public void Given4x4WordSearchPuzzleWhenSecondRowLocationListToGetStringFromLocationsThenGetStringFromLocationsReturnsRRJA(WordSearchPuzzle puzzle) { IDirectionSearchStrategy sut = CreateInstance(puzzle); List <Vector2> secondRow = new List <Vector2>(); secondRow.Add(new Vector2(0, 1)); secondRow.Add(new Vector2(1, 1)); secondRow.Add(new Vector2(2, 1)); secondRow.Add(new Vector2(3, 1)); String result = sut.GetStringFromLocations(secondRow); String expected = "RRJA"; Assert.AreEqual(expected, result); }
public void GivenValidPuzzleWithTwoWordsWhenCallingGetWordsMapThenGetWordsMapReturnsAWordsMapDecoratorWithTwoWords(WordSearchPuzzle puzzle, WordsMapDecorator expected) { sut = new WordsLocationFinder(puzzle); WordsMapDecorator result = sut.GetWordsMap(); Assert.AreEqual(expected, result); }
public void Given4x4WordWithTwoUpWordsPuzzleWhenCallingSearchEachWordsThenSearchEachWordReturnsAStringVector2DictionaryWithEntryForKIRKAndKHAN(WordSearchPuzzle puzzle, Dictionary <String, List <Vector2> > expected) { puzzle.AddWord("KHAN"); DirectionSearchFactory directionSearchFactory = new DirectionSearchFactory(puzzle); sut = new WordSearchAlgorithm(directionSearchFactory, puzzle.WordsList); Dictionary <String, List <Vector2> > result = sut.SearchEachWord(); List <Vector2> khanLocation = new List <Vector2>(); khanLocation.Add(new Vector2(3, 3)); khanLocation.Add(new Vector2(3, 2)); khanLocation.Add(new Vector2(3, 1)); khanLocation.Add(new Vector2(3, 0)); expected.Add("KHAN", khanLocation); Assert.AreEqual(expected, result); }
public void Given4x4WordSearchPuzzleWhenFirstRowLocationListToGetStringFromLocationsThenGetStringFromLocationsReturnsKEFN(WordSearchPuzzle puzzle) { IDirectionSearchStrategy sut = CreateInstance(puzzle); List <Vector2> firstRow = new List <Vector2>(); firstRow.Add(new Vector2(0, 0)); firstRow.Add(new Vector2(1, 0)); firstRow.Add(new Vector2(2, 0)); firstRow.Add(new Vector2(3, 0)); String result = sut.GetStringFromLocations(firstRow); String expected = "KEFN"; Assert.AreEqual(expected, 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 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 Given4x4WordPuzzleWithWordNotInPuzzleWhenCallingSearchEachWordsThenSearchEachWordLicationsThrowsNoException(WordSearchPuzzle puzzle) { puzzle.AddWord("UHURA"); DirectionSearchFactory directionSearchFactory = new DirectionSearchFactory(puzzle); sut = new WordSearchAlgorithm(directionSearchFactory, puzzle.WordsList); sut.SearchEachWord(); }
public void GivenValidPuzzleWhenCallingGetWordsMapThenGetWordsMapDoesNotReturnNull(WordSearchPuzzle puzzle) { sut = new WordsLocationFinder(puzzle); sut.GetWordsMap(); }
protected abstract IDirectionSearchStrategy CreateInstance(WordSearchPuzzle puzzle);
public void GivenValidPuzzleWhenCallingGetWordsMapThenGetWordsMapReturnsAWordsMapDecorator(WordSearchPuzzle puzzle) { sut = new WordsLocationFinder(puzzle); WordsMapDecorator result = sut.GetWordsMap(); Assert.IsInstanceOf <WordsMapDecorator>(result); }
public void Given4x4WordSearchPuzzleWhenPassingStarting00and4ToGetNeighborsFromThenGetNeighborsFromDoesNotReturnNull(WordSearchPuzzle puzzle) { IDirectionSearchStrategy sut = CreateInstance(puzzle); Vector2 startLocation = new Vector2(0, 0); int length = 4; List <Vector2> result = sut.GetNeighborsFrom(startLocation, length); Assert.IsNotNull(result); }
public void GivenInvalidPuzzleWhenCallingGetWordsMapThenGetWordsMapThrowsInvalidDataException(WordSearchPuzzle puzzle) { sut = new WordsLocationFinder(puzzle); Assert.Throws <InvalidDataException>(new TestDelegate(GetWordsMapInvalidPuzzle)); }
protected override IDirectionSearchStrategy CreateInstance(WordSearchPuzzle puzzle) { return(new RightDirectionSearchStrategy(puzzle)); }
public void TestSolve() { WordSearchPuzzle puzzle = new WordSearchPuzzle("puzzle.txt", "words.txt"); puzzle.Solve(); }
public DownLeftDirectionSearchStrategy(WordSearchPuzzle wordSearchPuzzle) { puzzle = wordSearchPuzzle; }
public void Given5x5WordSearchPuzzleWhenPassing22And5ToGetNeighborsFromThenGetNeighborsFromReturnsVector2ListWith3Elements(WordSearchPuzzle puzzle) { IDirectionSearchStrategy sut = CreateInstance(puzzle); Vector2 startLocation = new Vector2(2, 2); int length = 5; List <Vector2> locations = sut.GetNeighborsFrom(startLocation, length); int result = locations.Count; int expected = 3; 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 Given4x4WordSearchPuzzleWhenPassing03And4ToGetNeighborsFromThenGetNeighborsFromReturnsListOfLocationsFrom03Right(WordSearchPuzzle puzzle) { IDirectionSearchStrategy sut = CreateInstance(puzzle); Vector2 startLocation = new Vector2(0, 3); int length = 4; List <Vector2> result = sut.GetNeighborsFrom(startLocation, length); List <Vector2> expected = new List <Vector2>(); expected.Add(new Vector2(0, 3)); expected.Add(new Vector2(1, 3)); expected.Add(new Vector2(2, 3)); expected.Add(new Vector2(3, 3)); Assert.AreEqual(expected, result); }
public void Given4x4WordSearchPuzzleWhenPassingKToGetAllLocationsOfLetterThenGetAllLocationsOfLetterDoesNotReturnNull(WordSearchPuzzle puzzle) { IDirectionSearchStrategy sut = CreateInstance(puzzle); List <Vector2> result = sut.GetAllLocationsOfLetter('K'); Assert.IsNotNull(result); }
public UpRightDirectionSearchStrategy(WordSearchPuzzle wordSearchPuzzle) { puzzle = wordSearchPuzzle; }
public void Given4x4WordSearchPuzzleWhenPassingEToGetAllLocationsOfLetterThenGetAllLocationsOfLetterReturnsLocationOf1E(WordSearchPuzzle puzzle) { IDirectionSearchStrategy sut = CreateInstance(puzzle); List <Vector2> result = sut.GetAllLocationsOfLetter('E'); List <Vector2> expected = new List <Vector2>(); expected.Add(new Vector2(1, 0)); Assert.AreEqual(expected, result); }