Beispiel #1
0
        public void RoundMatches_ShouldThrow_WhenRoundingWithoutBuild()
        {
            var searchTree = new SearchTree();

            searchTree.Add("_");
            searchTree.Build();
            searchTree.Add("~~");
            new Action(() => searchTree.RoundMatches("~_~~").ToList()).ShouldThrow <InvalidOperationException>();
        }
Beispiel #2
0
 public string RenderToHtml(string markdown)
 {
     if (markdown == null)
     {
         throw new ArgumentException();
     }
     using (var entityIterator = tagSearchTree.RoundMatches(markdown).GetEnumerator())
     {
         return(RecoursionTagRender(entityIterator, markdown));
     }
 }
Beispiel #3
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);
        }
Beispiel #4
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);
        }