コード例 #1
0
        public void FindAdjacentWords()
        {
            IEnumerable <String> results = testCharacterTrieUtilities.FindAdjacentWords(trieRoot, "time");

            Assert.AreEqual(0, results.Count());


            CharacterTrieBuilder builder = new CharacterTrieBuilder();

            builder.AddWord(trieRoot, "limb", true);
            builder.AddWord(trieRoot, "line", true);
            builder.AddWord(trieRoot, "lime", true);
            builder.AddWord(trieRoot, "time", true);
            builder.AddWord(trieRoot, "timo", true);
            builder.AddWord(trieRoot, "tame", true);
            builder.AddWord(trieRoot, "tile", true);
            builder.AddWord(trieRoot, "timer", true);
            builder.AddWord(trieRoot, "timers", true);
            builder.AddWord(trieRoot, "tamer", true);
            builder.AddWord(trieRoot, "lines", true);
            builder.AddWord(trieRoot, "liner", true);
            builder.AddWord(trieRoot, "tim", true);

            results = testCharacterTrieUtilities.FindAdjacentWords(trieRoot, "time");

            Assert.AreEqual(4, results.Count());
            Assert.IsTrue(results.Contains("lime"));
            Assert.IsTrue(results.Contains("tame"));
            Assert.IsTrue(results.Contains("tile"));
            Assert.IsTrue(results.Contains("timo"));
        }
コード例 #2
0
        public void AddWord_WordParameterEmptyString()
        {
            ArgumentException e = Assert.ThrowsException <ArgumentException>(() =>
            {
                testCharacterTrieBuilder.AddWord(trieRoot, "", true);
            });

            StringAssert.StartsWith(e.Message, "Parameter 'word' cannot be an empty string.");
            Assert.AreEqual("word", e.ParamName);
        }