Esempio n. 1
0
        public void TestTopByPrefix(
            IReadOnlyList <string> phrases, string prefix, int count, string[] expectedTopWords)
        {
            var actualTopWords = AutocompleteTask.GetTopByPrefix(phrases, prefix, count);

            CollectionAssert.AreEqual(actualTopWords, expectedTopWords);
        }
Esempio n. 2
0
        public void TopByPrefix_IsEmpty_WhenNoPhrases_AndCountIsGreaterThanZero()
        {
            var phrases = new List <string>();
            var result  = AutocompleteTask.GetTopByPrefix(phrases, "q", 5);

            CollectionAssert.IsEmpty(result);
        }
Esempio n. 3
0
        public void TopByPrefix_IsEmpty_WhenNoPhrases_CounterNonZero()
        {
            var phrases = new List <string>();
            var result  = AutocompleteTask.GetTopByPrefix(phrases, "C#", 1);

            CollectionAssert.IsEmpty(result);
        }
Esempio n. 4
0
        public void TopByPrefix_IsEmpty_WhenNoPhrases()
        {
            var topWords = AutocompleteTask.GetTopByPrefix(new List <string> {
            }, "a", 1);

            CollectionAssert.IsEmpty(topWords);
        }
Esempio n. 5
0
        public void TopByPrefixUniversalTest(string[] nonParsedPhrases,
                                             string prefix, int count, string[] expectedTopWords)
        {
            var phrases        = nonParsedPhrases.ToList().AsReadOnly();
            var actualTopWords = AutocompleteTask.GetTopByPrefix(phrases, prefix, count);

            Assert.AreEqual(expectedTopWords, actualTopWords);
        }
Esempio n. 6
0
        public void CountByPrefix_IsTotalCount_WhenEmptyPrefix()
        {
            var topWords = AutocompleteTask.GetTopByPrefix(new List <string> {
                "a", "b"
            }, "", 1);

            Assert.AreEqual(topWords, 0);
        }
Esempio n. 7
0
        public void TopByPrefix_IsEmpty_WhenNoPhrases()
        {
            var phrases        = new string[] { "a", "ab", "abc", "def" };
            var prefix         = "zzz";
            int count          = 10;
            var actualTopWords = AutocompleteTask.GetTopByPrefix(phrases, prefix, count);

            CollectionAssert.IsEmpty(actualTopWords);
        }
Esempio n. 8
0
        public void TopByPrefix_IsEmpty_WhenNoPhrases()
        {
            var list = new List <string> {
                "aa", "ab", "bc", "bd", "be", "ca", "cb"
            };
            var actualTopWords = AutocompleteTask.GetTopByPrefix(list, "z", 2);

            CollectionAssert.IsEmpty(actualTopWords);
        }
Esempio n. 9
0
        public void TopByPrefix_IsEmpty_WhenCounterZero()
        {
            var phrases = new List <string> {
                "a", "ab"
            };
            var result = AutocompleteTask.GetTopByPrefix(phrases, "a", 0);

            CollectionAssert.IsEmpty(result);
        }
Esempio n. 10
0
        public void TopByPrefix_IsEmpty_WhenNoPhrases()
        {
            var phrases        = new List <string>();
            var count          = 2;
            var prefix         = "ab";
            var actualTopWords = AutocompleteTask.GetTopByPrefix(phrases, prefix, count);

            CollectionAssert.IsEmpty(actualTopWords);
        }
Esempio n. 11
0
        public void TopByPrefix()
        {
            var phrases = new List <string> {
                "a", "ab", "ab"
            };
            var result = AutocompleteTask.GetTopByPrefix(phrases, "a", 10);

            Assert.AreEqual(3, result.Length);
            CollectionAssert.AreEqual(phrases, result);
        }
Esempio n. 12
0
        public void TopByPrefix_IsEmpty_WhenPhrasesNotContainPrefix_AndCountIsGreaterThanZero()
        {
            var phrases = new List <string>()
            {
                "nig", "nigg", "n***a"
            };
            var result = AutocompleteTask.GetTopByPrefix(phrases, "a", phrases.Count);

            CollectionAssert.IsEmpty(result);
        }
Esempio n. 13
0
        public void TopByPrefix_MultipleResult_Uncutted()
        {
            var phrases        = new string[] { "a", "ab", "abc", "def" };
            var prefix         = "ab";
            int count          = 10;
            var expectedResult = new string[] { "ab", "abc" };
            var actualTopWords = AutocompleteTask.GetTopByPrefix(phrases, prefix, count);

            CollectionAssert.Equals(expectedResult, actualTopWords);
        }
Esempio n. 14
0
        public void TopByPrefix_IsTotalCount_WhenPhrasesContainPrefix_AndCountIsGreaterThanTotal()
        {
            var phrases = new List <string>()
            {
                "nig", "nigg", "n***a"
            };
            var totalCount = phrases.Count;
            var result     = AutocompleteTask.GetTopByPrefix(phrases, "n", 42);

            Assert.AreEqual(totalCount, result.Length);
            CollectionAssert.AreEqual(phrases, result);
        }
Esempio n. 15
0
        public void TopByPrefix_IsEmpty_WhenNoPhrases()
        {
            var list = new List <string>()
            {
            };
            IReadOnlyList <string> phrases = list;
            var prefix         = "cdf";
            var count          = 1;
            var actualTopWords = AutocompleteTask.GetTopByPrefix(phrases, prefix, count);

            CollectionAssert.IsEmpty(actualTopWords);
        }
Esempio n. 16
0
        public void GetTopByPrefixTestEmpty()
        {
            var phrases = new List <string> {
                "a", "ab", "abc", "b"
            };
            var prefix         = "c";
            var count          = 2;
            var expectedResult = new string[0];
            var result         = AutocompleteTask.GetTopByPrefix(phrases, prefix, count);

            Assert.AreEqual(expectedResult, result);
        }
Esempio n. 17
0
        public void GetTopByPrefixTestLessThanCount()
        {
            var phrases = new List <string> {
                "a", "ab", "abc", "b"
            };
            var prefix         = "a";
            var count          = 4;
            var expectedResult = new[] { "a", "ab", "abc" };
            var result         = AutocompleteTask.GetTopByPrefix(phrases, prefix, count);

            Assert.AreEqual(expectedResult, result);
        }
Esempio n. 18
0
        public void TopByPrefix_IsEmpty_WhenCountIsZero()
        {
            var phrases = new List <string>()
            {
                "aa", "ab", "abb", "abc", "ac", "csa"
            };
            var prefix         = "ab";
            var count          = 0;
            var actualTopWords = AutocompleteTask.GetTopByPrefix(phrases, prefix, count);

            CollectionAssert.IsEmpty(actualTopWords);
        }
Esempio n. 19
0
        public void TopByPrefix_IsEmpty_WhenEmptyPrefix()
        {
            var phrases = new List <string>()
            {
                "aa", "ab", "abb", "abc", "ac", "csa"
            };
            var prefix         = "";
            var count          = 2;
            var actualTopWords = AutocompleteTask.GetTopByPrefix(phrases, prefix, count);
            var expectedResult = new String[] { "aa", "ab" };

            Assert.AreEqual(expectedResult, actualTopWords);
        }
Esempio n. 20
0
        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));
        }
Esempio n. 21
0
        public void TopByPrefix_IsEmpty_WhenCountIsLargerThanActualTopWords()
        {
            var phrases = new List <string>()
            {
                "aa", "ab", "abb", "abc", "ac", "csa"
            };
            var prefix         = "ab";
            var count          = 10;
            var actualTopWords = AutocompleteTask.GetTopByPrefix(phrases, prefix, count);
            var expectedCount  = new String[] { "ab", "abb", "abc" };

            Assert.AreEqual(expectedCount, actualTopWords);
        }
Esempio n. 22
0
        public void TopByPrefix_IsEmpty_WhenNoPhrases()
        {
            var checkList = new List <string>();
            var prefix    = "df";
            IReadOnlyList <string> myReadOnlyList = checkList;
            var checkResult = AutocompleteTask.GetTopByPrefix(myReadOnlyList, prefix, 5);

            for (var i = 0; i < checkResult.Length; i++)
            {
                checkList[i] = checkResult[i];
            }
            CollectionAssert.IsEmpty(checkList);
        }
Esempio n. 23
0
        public void TopByPrefix_IsNCount_WhenPhrasesContainPrefix_AndCountIsN()
        {
            var phrases = new List <string>()
            {
                "nig", "n***a", "nigger", "niggeroid"
            };
            var expected = new List <string>()
            {
                "nig", "n***a"
            };
            var n      = expected.Count;
            var result = AutocompleteTask.GetTopByPrefix(phrases, "ni", n);

            Assert.AreEqual(n, result.Length);
            CollectionAssert.AreEqual(expected, result);
        }
Esempio n. 24
0
 public void TopByPrefix_IsEmpty_WhenNoPhrases(string[] phrases, string prefix, int count)
 {
     CollectionAssert.IsEmpty(AutocompleteTask.GetTopByPrefix(phrases, prefix, count));
 }