Example #1
0
        public void TestCountByPrefix(
            IReadOnlyList <string> phrases, string prefix, int expectedCount)
        {
            var actualCount = AutocompleteTask.GetCountByPrefix(phrases, prefix);

            Assert.AreEqual(actualCount, expectedCount);
        }
Example #2
0
        public void CountByPrefix_IsZero_WhenNoPhrases()
        {
            var phrases = new List <string>();
            var result  = AutocompleteTask.GetCountByPrefix(phrases, "q");

            Assert.AreEqual(0, result);
        }
Example #3
0
        public void CountByPrefixUniversalTest(IReadOnlyList <string> nonPaArsedPhrases, string prefix,
                                               int expectedCount)
        {
            var phrases     = nonPaArsedPhrases.ToList().AsReadOnly();
            var actualCount = AutocompleteTask.GetCountByPrefix(phrases, prefix);

            Assert.AreEqual(expectedCount, actualCount);
        }
Example #4
0
        public void CountByPrefix_IsTotalCount_WhenEmptyPrefix()
        {
            var list = new List <string> {
                "aa", "ab", "bc", "bd", "be", "ca", "cb"
            };
            var actualCount = AutocompleteTask.GetCountByPrefix(list, "a");

            Assert.AreEqual(2, actualCount);
        }
Example #5
0
        public void CountByPrefix_IsTotalCount_WhenMultipleResult()
        {
            var phrases       = new string[] { "a", "ab", "abc", "def" };
            var prefix        = "a";
            var expectedCount = 3;
            var actualCount   = AutocompleteTask.GetCountByPrefix(phrases, prefix);

            Assert.AreEqual(expectedCount, actualCount);
        }
Example #6
0
        public void CountByPrefix_IsZero_WhenNoEntries()
        {
            var phrases = new List <string>()
            {
                "a", "hitler", "super", "test"
            };
            var result = AutocompleteTask.GetCountByPrefix(phrases, "hitla");

            Assert.AreEqual(0, result);
        }
Example #7
0
        public void CountByPrefix_IsTotalCount_WhenAllContainPrefix()
        {
            var phrases = new List <string>()
            {
                "mmcs", "mmc", "mm", "m"
            };
            var result = AutocompleteTask.GetCountByPrefix(phrases, "m");

            Assert.AreEqual(4, result);
        }
Example #8
0
        public void CountByPrefix_IsTotalCount()
        {
            var phrases = new List <string>()
            {
                "m", "m", "c", "s"
            };
            var result = AutocompleteTask.GetCountByPrefix(phrases, "m");

            Assert.AreEqual(2, result);
        }
Example #9
0
        public void CountByPrefix_IsTotalCount_WhenEmptyPhrases()
        {
            var phrases = new List <string>()
            {
            };
            var prefix         = "ab";
            var actualTopWords = AutocompleteTask.GetCountByPrefix(phrases, prefix);
            var expectedCount  = 0;

            Assert.AreEqual(expectedCount, actualTopWords);
        }
        public void GetCountByPrefixEmptyTest()
        {
            var phrases = new List <string> {
                "a", "ab", "abc", "b"
            };
            var prefix         = "c";
            var expectedResult = 0;
            var result         = AutocompleteTask.GetCountByPrefix(phrases, prefix);

            Assert.AreEqual(expectedResult, result);
        }
Example #11
0
        public void CountByPrefix_IsTotalCount_WhenEmptyPrefix()
        {
            var phrases = new List <string>()
            {
                "i", "love", "programming"
            };
            var totalCount = phrases.Count;
            var result     = AutocompleteTask.GetCountByPrefix(phrases, "");

            Assert.AreEqual(totalCount, result);
        }
Example #12
0
        public void CountByPrefix_IsTotalCount_WhenAllPhrasesContainPrefix()
        {
            var phrases = new List <string>()
            {
                "he", "hell", "hello", "help"
            };
            var totalCount = phrases.Count;
            var result     = AutocompleteTask.GetCountByPrefix(phrases, "he");

            Assert.AreEqual(totalCount, result);
        }
Example #13
0
        public void CountByPrefix_IsN_WhenHaveNEntries()
        {
            var phrases = new List <string>()
            {
                "alrite", "another", "hitler", "hitt"
            };
            var n      = 2;
            var result = AutocompleteTask.GetCountByPrefix(phrases, "hit");

            Assert.AreEqual(n, result);
        }
Example #14
0
        public void CountByPrefix_IsTotalCount_WhenEmptyPrefix()
        {
            var phrases = new List <string>()
            {
                "aa", "ab", "abb", "abc", "ac", "csa"
            };
            var prefix         = "";
            var actualTopWords = AutocompleteTask.GetCountByPrefix(phrases, prefix);
            var expectedCount  = phrases.Count;

            Assert.AreEqual(expectedCount, actualTopWords);
        }
Example #15
0
        public void CountByPrefix_IsTotalCount_NoPhrasesThatStartsWithPrefix()
        {
            var phrases = new List <string>()
            {
                "aa", "ab", "abb", "abc", "ac", "csa"
            };
            var prefix         = "cb";
            var actualTopWords = AutocompleteTask.GetCountByPrefix(phrases, prefix);
            var expectedCount  = 0;

            Assert.AreEqual(expectedCount, actualTopWords);
        }
Example #16
0
        public void CountByPrefix_IsTotalCount_PrefixIsInTheEndOfRow()
        {
            var phrases = new List <string>()
            {
                "aa", "ab", "abb", "abc", "ac", "csa", "css"
            };
            var prefix         = "cs";
            var actualTopWords = AutocompleteTask.GetCountByPrefix(phrases, prefix);
            var expectedCount  = 3;

            Assert.AreEqual(expectedCount, actualTopWords);
        }
Example #17
0
        public void CountByPrefix_IsTotalCount_WhenEmptyPrefix()
        {
            var checkList = new List <string>()
            {
                "ab", "abcd", "cde", "drtu", "jklk", "vhkj"
            };
            var prefix = "";
            IReadOnlyList <string> myReadOnlyList = checkList;
            var actualCount   = AutocompleteTask.GetCountByPrefix(myReadOnlyList, prefix);
            var expectedCount = checkList.Count;

            Assert.AreEqual(expectedCount, actualCount);
        }
        private Tuple <TimeSpan, string[], int> FindItems(string prefix)
        {
            var sw              = Stopwatch.StartNew();
            var foundItems      = AutocompleteTask.GetTopByPrefix(phrases, prefix, 10);
            var foundItemsCount = AutocompleteTask.GetCountByPrefix(phrases, prefix);

            if (foundItems == null)
            {
                var oneItem = AutocompleteTask.FindFirstByPrefix(phrases, prefix);
                foundItems = oneItem != null ? new[] { oneItem } : new string[0];
            }
            return(Tuple.Create(sw.Elapsed, foundItems, foundItemsCount));
        }
Example #19
0
        public void CountByPrefix_IsTotalCount_WhenEmptyPrefix()
        {
            var list = new  List <string>()
            {
                "a", "bb", "c"
            };
            IReadOnlyList <string> phrases = list;
            var prefix        = "";
            var expectedCount = 3;
            var actualCount   = AutocompleteTask.GetCountByPrefix(phrases, prefix);

            Assert.AreEqual(expectedCount, actualCount);
        }
Example #20
0
 public void CountByPrefix_IsTotalCount_WhenEmptyPrefix(string[] phrases, string prefix, int expectedCount)
 {
     Assert.AreEqual(expectedCount, AutocompleteTask.GetCountByPrefix(phrases, prefix));
 }