Esempio n. 1
0
        void InternalTest(char[][] board, string[] words, List <string> expected)
        {
            List <string> actual = WordSearchII.FindWords(board, words);

            Assert.Equal <int>(expected.Count, actual.Count);
            foreach (string word in expected)
            {
                Assert.Contains(word, actual);
            }
        }
Esempio n. 2
0
        public void Test01_For_NbyM_Grid()
        {
            // Arrange
            var instance = new WordSearchII();
            var grid     = new char[, ]
            {
                { 'a', 'a' }
            };
            var dictionary = new List <string> {
                "aaa"
            };

            // Act
            var wordsFound = instance.FindDictionaryWordsInTheGrid(dictionary, grid);

            // Assert
            Assert.AreEqual(0, wordsFound.ToList().Count);
        }
Esempio n. 3
0
        public void Test01_For_NbyN_Grid()
        {
            // Arrange
            var instance = new WordSearchII();
            var grid     = new char[, ]
            {
                { 'o', 'a', 'a', 'n' },
                { 'e', 't', 'a', 'e' },
                { 'i', 'h', 'k', 'r' },
                { 'i', 'f', 'l', 'v' }
            };
            var dictionary = new List <string> {
                "oath", "pea", "eat", "rain"
            };

            // Act
            var wordsFound = instance.FindDictionaryWordsInTheGrid(dictionary, grid);

            // Assert
            Assert.AreEqual(2, wordsFound.ToList().Count);
        }