public void IntersectionWordFound(int StartRow1, int StartColumn1, string boardWord1, int StartRow2, int StartColumn2, string boardWord2, int r, int c, Direction direction, bool expectedResult) { //arrange var MockFileService = new Mock <FileService>(); MockFileService.Setup(f => f.OpenFileStream(It.IsAny <string>())).Returns((() => TestFormatters.StringToStream(testDictionaryFile))); var wordList = new WordList(MockFileService.Object) { }; wordList.LoadDictionary(DictionaryEdition.ENABLE); var validationStrategy = new IntersectingNeighborValidationStrategy(wordList); var boardModel = new BoardLettersModel(16, 16); boardModel.PlaceWord(StartRow1, StartColumn1, boardWord1, new Direction(0, 1)); boardModel.PlaceWord(StartRow2, StartColumn2, boardWord2, new Direction(1, 0)); var directionData = new RightDownSubstituteDirectionStrategy.DirectionData() { WordDirection = direction }; //act var result = validationStrategy.Validate(boardModel, "TEST", r, c, directionData); //assert Assert.Equal(expectedResult, result); }
void ReadWord_WhenCoordsInMiddleOfWord_ReadsWordFromBeginning() { //arrange var testWord = "TEST"; var board = new BoardLettersModel(4, 4); board.PlaceWord(0, 0, testWord, new Direction(0, 1)); //act var word = board.ReadWord(0, 2, new Direction(0, 1)); //assert Assert.Equal(testWord, word); }
void ReadWord_WhenCalled_ReadsWord() { //arrange var testWord = "TEST"; var board = new BoardLettersModel(4, 4); board.PlaceWord(0, 0, testWord, new Direction(0, 1)); //act var word = board.ReadWord(0, 0, new Direction(0, 1)); //assert Assert.Equal(testWord, word); }
void PlaceWord_WhenWordTooLong_Truncates() { //arrange var board = new BoardLettersModel(4, 4); //act board.PlaceWord(0, 0, "LONGWORD", new Direction(0, 1)); //assert Assert.Equal('L', board.Letters[0, 0]); Assert.Equal('O', board.Letters[0, 1]); Assert.Equal('N', board.Letters[0, 2]); Assert.Equal('G', board.Letters[0, 3]); }
void PlaceWord_WhenCalledWithDirection_PlacesWordInCorectDirection() { //arrange var board = new BoardLettersModel(4, 4); //act board.PlaceWord(0, 0, "TEST", new Direction(1, 0)); //assert Assert.Equal('T', board.Letters[0, 0]); Assert.Equal('E', board.Letters[1, 0]); Assert.Equal('S', board.Letters[2, 0]); Assert.Equal('T', board.Letters[3, 0]); }
void PlaceWord_WhenCalled_PlacesWord() { //arrange var board = new BoardLettersModel(4, 4); //act board.PlaceWord(0, 0, "TEST", new Direction(0, 1)); //assert Assert.Equal('T', board.Letters[0, 0]); Assert.Equal('E', board.Letters[0, 1]); Assert.Equal('S', board.Letters[0, 2]); Assert.Equal('T', board.Letters[0, 3]); }
void PlaceWord_WhenCalledWithLocation_PlacesWordInCorrectLocation() { //arrange var board = new BoardLettersModel(10, 10); //act board.PlaceWord(3, 5, "HELLO", new Direction(0, 1)); //assert Assert.Equal('H', board.Letters[3, 5]); Assert.Equal('E', board.Letters[3, 6]); Assert.Equal('L', board.Letters[3, 7]); Assert.Equal('L', board.Letters[3, 8]); Assert.Equal('O', board.Letters[3, 9]); }
public void WordFoundUsingSubstituteLetters(int StartRow, int StartColumn, bool horizonal, string boardWord, string subLetters, string expectedWord, bool expectedToFind) { //arrange var MockFileService = new Mock <FileService>(); MockFileService.Setup(f => f.OpenFileStream(It.IsAny <string>())).Returns((() => TestFormatters.StringToStream(testDictionaryFile))); var wordList = new WordList(MockFileService.Object) { }; wordList.LoadDictionary(DictionaryEdition.ENABLE); var boardModel = new BoardLettersModel(16, 16); boardModel.PlaceWord(0, 0, boardWord, horizonal ? new Direction(0, 1) : new Direction(1, 0)); var substituionLetters = new BoardLettersModel(1, 7); substituionLetters.PlaceWord(0, 0, subLetters, new Direction(0, 1)); var wordFinder = new WordFinder.WordFinder(boardModel, wordList, new RightDownSubstituteDirectionStrategy(substituionLetters)); //act List <Word> words = wordFinder.FindWords(); //assert var word = words.Find(w => w.Text == expectedWord); if (expectedToFind) { Assert.NotNull(word); } else { Assert.Null(word); } }
public WordScorer(BoardLettersModel boardModel) { this.board = boardModel; }
public abstract bool ValidateWordEnd(BoardLettersModel boardModel, string prefix, int r, int c, object directionData, bool substitionsMade, bool lettersWithoutSubstitions);
public abstract bool Validate(BoardLettersModel boardModel, string prefix, int r, int c, object directionData);