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); } }