Exemplo n.º 1
0
        public void Adding10000RandomKeysAndStartsWithFindsRandomKeysWork()
        {
            var randomKeys = Keygenerator.GenerateKeys(57, 20, '0', 'z', 10000);
            var random     = new Random(57);

            var searchDictionary = new SearchDictionary <string>();

            foreach (var randomKey in randomKeys)
            {
                searchDictionary.Add(randomKey, randomKey);
            }

            foreach (var randomKey in randomKeys)
            {
                var length     = random.Next(1, randomKey.Length + 1);
                var startOfKey = randomKey.Substring(0, length);

                var foundValues  = searchDictionary.StartsWith(startOfKey).OrderBy(value => value).ToArray();
                var actualValues = randomKeys.Where(key => key.StartsWith(startOfKey)).OrderBy(value => value).ToArray();

                CollectionAssert.AreEqual(foundValues, actualValues);
            }
        }
Exemplo n.º 2
0
 public override int StartsWith()
 {
     return(searchDictionary.StartsWith(RepeatedKeys[KeyIndex++]).Sum());
 }
Exemplo n.º 3
0
        public void StartsWith()
        {
            var dictionary = new SearchDictionary <string>
            {
                { "testa", "testa" },
                { "testb", "testb" },
                { "test", "test" },
                { "tesk", "tesk" }
            };

            CollectionAssert.AreEqual(new[] { "testa", "testb", "test" }.OrderBy(v => v).ToArray(), dictionary.StartsWith("test").OrderBy(v => v).ToArray());
        }