コード例 #1
0
        public void AddEntry_called_with_existing_entry_does_not_update_usage_count()
        {
            ConfigureProvider();

            // try to make this the "t"-word with the highest usage
            autoComplete.AddEntry("these", new DictionaryEntry("these", 101));

            var suggestions = autoComplete.GetSuggestions("t");

            Assert.AreNotEqual("these", suggestions.First());
        }
コード例 #2
0
        public SpellingCorrectionTestResult TestWord(MisspellingTest misspellingTest)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            var charactersTyped = -1;

            for (var n = 1; n <= misspellingTest.Misspelling.Length; ++n)
            {
                var typedSoFar  = misspellingTest.Misspelling.Substring(0, n);
                var suggestions = autoComplete.GetSuggestions(typedSoFar).Take(NumberOfSuggestionsToCheck);

                if (!suggestions.Any(
                        suggestion =>
                        suggestion.Equals(misspellingTest.TargetWord, StringComparison.CurrentCultureIgnoreCase)))
                {
                    continue;
                }

                charactersTyped = n;
                break;
            }
            stopwatch.Stop();

            var timeTaken = stopwatch.Elapsed;

            return(new SpellingCorrectionTestResult(charactersTyped, timeTaken, misspellingTest));
        }
コード例 #3
0
 public IEnumerable <string> GetAutoCompleteSuggestions(string root)
 {
     return(manageAutoComplete.GetSuggestions(root));
 }