public void TestTopByPrefix( IReadOnlyList <string> phrases, string prefix, int count, string[] expectedTopWords) { var actualTopWords = AutocompleteTask.GetTopByPrefix(phrases, prefix, count); CollectionAssert.AreEqual(actualTopWords, expectedTopWords); }
public void TopByPrefix_IsEmpty_WhenNoPhrases_AndCountIsGreaterThanZero() { var phrases = new List <string>(); var result = AutocompleteTask.GetTopByPrefix(phrases, "q", 5); CollectionAssert.IsEmpty(result); }
public void TopByPrefix_IsEmpty_WhenNoPhrases_CounterNonZero() { var phrases = new List <string>(); var result = AutocompleteTask.GetTopByPrefix(phrases, "C#", 1); CollectionAssert.IsEmpty(result); }
public void TopByPrefix_IsEmpty_WhenNoPhrases() { var topWords = AutocompleteTask.GetTopByPrefix(new List <string> { }, "a", 1); CollectionAssert.IsEmpty(topWords); }
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); }
public void CountByPrefix_IsTotalCount_WhenEmptyPrefix() { var topWords = AutocompleteTask.GetTopByPrefix(new List <string> { "a", "b" }, "", 1); Assert.AreEqual(topWords, 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); }
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); }
public void TopByPrefix_IsEmpty_WhenCounterZero() { var phrases = new List <string> { "a", "ab" }; var result = AutocompleteTask.GetTopByPrefix(phrases, "a", 0); CollectionAssert.IsEmpty(result); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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 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); }
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)); }
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); }
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); }
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); }
public void TopByPrefix_IsEmpty_WhenNoPhrases(string[] phrases, string prefix, int count) { CollectionAssert.IsEmpty(AutocompleteTask.GetTopByPrefix(phrases, prefix, count)); }