Esempio n. 1
0
        public void GetCountByPrefixEmptyTest()
        {
            var phrases = new List <string> {
                "a", "ab", "abc", "b"
            };
            var prefix         = "c";
            var expectedResult = 0;
            var result         = My_AutocompleteTask.GetCountByPrefix(phrases, prefix);

            Assert.AreEqual(expectedResult, result);
        }
Esempio n. 2
0
        private Tuple <TimeSpan, string[], int> FindItems(string prefix)
        {
            var sw              = Stopwatch.StartNew();
            var foundItems      = My_AutocompleteTask.GetTopByPrefix(phrases, prefix, 10);
            var foundItemsCount = My_AutocompleteTask.GetCountByPrefix(phrases, prefix);

            if (foundItems == null)
            {
                var oneItem = My_AutocompleteTask.FindFirstByPrefix(phrases, prefix);
                foundItems = oneItem != null ? new[] { oneItem } : new string[0];
            }

            return(Tuple.Create(sw.Elapsed, foundItems, foundItemsCount));
        }