Example #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);
        }
Example #2
0
        public void TopByPrefix_IsEmpty_WhenNoPhrases()
        {
            var topWords = AutocompleteTask.GetTopByPrefix(new List <string> {
            }, "a", 1);

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

            CollectionAssert.IsEmpty(result);
        }
Example #4
0
        public void CountByPrefix_IsZero_WhenNoPhrases()
        {
            var phrases = new List <string>();
            var result  = AutocompleteTask.GetCountByPrefix(phrases, "q");

            Assert.AreEqual(0, result);
        }
Example #5
0
        public void TopByPrefix_IsEmpty_WhenNoPhrases_AndCountIsGreaterThanZero()
        {
            var phrases = new List <string>();
            var result  = AutocompleteTask.GetTopByPrefix(phrases, "q", 5);

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

            Assert.AreEqual(actualCount, expectedCount);
        }
Example #7
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);
        }
Example #8
0
        public void CountByPrefix_IsTotalCount_WhenEmptyPrefix()
        {
            var topWords = AutocompleteTask.GetTopByPrefix(new List <string> {
                "a", "b"
            }, "", 1);

            Assert.AreEqual(topWords, 0);
        }
Example #9
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 #10
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 #11
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);
        }
Example #12
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);
        }
Example #13
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 #14
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);
        }
Example #15
0
        public void TopByPrefix_IsEmpty_WhenCounterZero()
        {
            var phrases = new List <string> {
                "a", "ab"
            };
            var result = AutocompleteTask.GetTopByPrefix(phrases, "a", 0);

            CollectionAssert.IsEmpty(result);
        }
Example #16
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 #17
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 #18
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);
        }
Example #19
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);
        }
Example #20
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);
        }
Example #21
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 #22
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 #24
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 #25
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 #26
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);
        }
        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);
        }
Example #28
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);
        }
        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);
        }
Example #30
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);
        }