コード例 #1
0
        public void TestNonWordsAreExcluded()
        {
            var dictionary = BoggleLibraryUtils.BuildDictionary(CodeSampleCoreUtils.ReturnWordList());

            var containsWord = BoggleLibraryUtils.ContainsWord("woeiruwoeiruwoeiur", dictionary);

            Assert.IsFalse(containsWord, "What we typed in is not a word");
        }
コード例 #2
0
        public void TestFullLoadOfWords()
        {
            string[] lines = CodeSampleCoreUtils.ReturnWordList();

            var dictionary = BoggleLibraryUtils.BuildDictionary(lines);

            foreach (string word in lines)
            {
                var containsWord = BoggleLibraryUtils.ContainsWord(word, dictionary);
                Assert.IsTrue(containsWord, "We expect to find this word: " + word);
            }
        }
コード例 #3
0
        List <string> IBoggleService.GetBoggleAnswers(BoggleDataContract input)
        {
            // NOTE: Here is where there should be a large amount of logic for error handling and other checking
            // Because this is a code sample, I chose not to include it for the sake of time. In a production service
            // There would be a large number of checks looking for propper inputs and responding appropriatelyj

            // This isn't thread safe, I need to look further into how WCF services handle threads and locking
            if (dictionary == null)
            {
                dictionary = BoggleLibraryUtils.BuildDictionary(CodeSampleCoreUtils.ReturnWordList());
            }

            return(BoggleSolver.SolveBoggle(input.Height, input.Width, input.Board, input.MinWordSize, dictionary));
        }
コード例 #4
0
        public void TestBoggleSolverAgainstBungieKnownGood()
        {
            var dictionary = BoggleLibraryUtils.BuildDictionary(CodeSampleCoreUtils.ReturnWordList());

            char[][] board = new char[3][]
            {
                new char[] { 'y', 'o', 'x' },
                new char[] { 'r', 'b', 'a' },
                new char[] { 'v', 'e', 'd' }
            };

            string[] bungieWords =
            {
                "bred",
                "yore",
                "byre",
                "abed",
                "oread",
                "bore",
                "orby",
                "robed",
                "broad",
                "byroad",
                "robe",
                "bored",
                "derby",
                "bade",
                "aero",
                "read",
                "orbed",
                "verb",
                "aery",
                "bead",
                "bread",
                "very",
                "road"
            };

            var foundWords = BoggleSolver.SolveBoggle(3, 3, board, 4, dictionary);

            foreach (string word in bungieWords)
            {
                Assert.IsTrue(foundWords.Contains(word), "We should have found, but didn't: " + word);
            }
        }
コード例 #5
0
 public static void InitializeClass(TestContext context)
 {
     wordList = CodeSampleCoreUtils.ReturnWordList();
 }