Пример #1
0
        public void RoundMatches_ShouldThrow_WhenRoundingWithoutBuild()
        {
            var searchTree = new SearchTree();

            searchTree.Add("_");
            searchTree.Build();
            searchTree.Add("~~");
            new Action(() => searchTree.RoundMatches("~_~~").ToList()).ShouldThrow <InvalidOperationException>();
        }
Пример #2
0
        public SearchTree BuildTagSearchTree(Dictionary <string, string> tagDictionary)
        {
            var tree = new SearchTree();

            foreach (var pair in tagDictionary)
            {
                tree.Add(pair.Key);
            }
            tree.Build();
            return(tree);
        }
Пример #3
0
        public Md()
        {
            var tagDictionary = new Dictionary <string, string>
            {
                { "_", "em" },
                { "__", "strong" },
                { "~~", "strike" }
            };

            htmlWriter    = new HtmlWriter(tagDictionary);
            tagSearchTree = BuildTagSearchTree(tagDictionary);
        }
Пример #4
0
        public void RoundMatches_ShouldFind_WhenAddPatternAfterBuild()
        {
            var searchTree = new SearchTree();

            searchTree.Add("_");
            searchTree.Build();
            searchTree.Add("___");
            searchTree.Build();
            var result   = searchTree.RoundMatches("___").ToList();
            var expected = new List <IMatch> {
                new PatternMatch("___", 0)
            };

            CollectionAssert.AreEqual(expected, result);
        }
Пример #5
0
        public void RoundMatches_ShouldFind_WhenDifferentPatterns()
        {
            var searchTree = new SearchTree();

            searchTree.Add("~");
            searchTree.Add("_");
            searchTree.Add("_~");
            searchTree.Add("__");
            searchTree.Build();
            var result   = searchTree.RoundMatches("__ _~ _~~").ToList();
            var expected = new List <IMatch>
            {
                new PatternMatch("__", 0),
                new SymbolMatch(' ', 2),
                new PatternMatch("_~", 3),
                new SymbolMatch(' ', 5),
                new PatternMatch("_~", 6),
                new PatternMatch("~", 8)
            };

            CollectionAssert.AreEqual(expected, result);
        }