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