예제 #1
0
        public void GetKeysWithPrefixTest()
        {
            var dictionary = new Dictionary <string, int>
            {
                { "she", 0 },
                { "sells", 0 },
                { "shells", 0 },
                { "sea", 0 },
                { "shore", 0 }
            };

            var prefix = "s";

            var allKeys = _symbolTable.GetKeysWithPrefix(prefix);

            var expected = 5;
            var actual   = CheckKeys(allKeys, dictionary);

            Assert.AreEqual(expected, actual);

            dictionary.Clear();

            dictionary.Add("she", 0);
            dictionary.Add("shells", 0);
            dictionary.Add("shore", 0);

            prefix = "sh";

            allKeys = _symbolTable.GetKeysWithPrefix(prefix);

            expected = 3;
            actual   = CheckKeys(allKeys, dictionary);
            Assert.AreEqual(expected, actual);

            prefix = "Invalid";

            expected = 0;
            allKeys  = _symbolTable.GetKeysWithPrefix(prefix);
            actual   = allKeys.Count();
            Assert.AreEqual(expected, actual);
        }