public void TestBuildTree_OnOuterTagClosedBeforeInner() { var tokens = new[] { new Token(TokenType.Tag, "__"), new Token(TokenType.Text, "a"), new Token(TokenType.Space, " "), new Token(TokenType.Tag, "_"), new Token(TokenType.Text, "b"), new Token(TokenType.Tag, "__"), new Token(TokenType.Space, " "), new Token(TokenType.Text, "c"), new Token(TokenType.Tag, "_"), }; var expectedTree = testTreeBuilder .WithTag(TestTreeBuilder .Tag(new BoldTagInfo()) .WithText("a") .WithSpace() .WithText("_") .WithText("b") .Build()) .WithSpace() .WithText("c") .WithText("_") .Build(); var tree = builder.BuildTree(tokens); tree.Should().BeEquivalentTo(expectedTree); }
public void TestBuildTree_OnSameClosingItalicTag() { var tokens = new[] { new Token(TokenType.Tag, "_"), new Token(TokenType.Text, "a"), new Token(TokenType.Tag, "_"), new Token(TokenType.Space, " "), new Token(TokenType.Text, "b"), new Token(TokenType.Tag, "_") }; var expectedTree = testTreeBuilder .WithTag(TestTreeBuilder .Tag(new ItalicTagInfo()) .WithText("a") .Build()) .WithSpace() .WithText("b") .WithText("_") .Build(); var tree = builder.BuildTree(tokens); tree.Should().BeEquivalentTo(expectedTree); }
public void SetUp() { translations = new MarkdownLanguage().GetTranslations; tagTranslator = new MarkdownToHtmlTagTranslator(translations); nodeTranslator = new MarkdownNodeTranslator(tagTranslator); treeTranslator = new MarkdownTokenTreeTranslator(nodeTranslator); treeBuilder = TestTreeBuilder.Tree(); }
public void TestTranslate_OnHeading6WithText() { const string expectedTranslation = "<h6>a</h6>"; var tree = treeBuilder .WithTag(TestTreeBuilder .Tag(new H6TagInfo()) .WithText("a") .Build()) .Build(); var translation = treeTranslator.Translate(tree); translation.Should().BeEquivalentTo(expectedTranslation); }
public void TestTranslate_OnBoldTagWithText() { const string expectedTranslation = "<strong>a</strong>"; var tree = treeBuilder .WithTag(TestTreeBuilder .Tag(new BoldTagInfo()) .WithText("a") .Build()) .Build(); var translation = treeTranslator.Translate(tree); translation.Should().BeEquivalentTo(expectedTranslation); }
public void TestTranslate_OnSameClosingItalicTag() { const string expectedTranslation = "<em>a</em> b_"; var tree = treeBuilder .WithTag(TestTreeBuilder .Tag(new ItalicTagInfo()) .WithText("a") .Build()) .WithSpace() .WithText("b") .WithText("_") .Build(); var translation = treeTranslator.Translate(tree); translation.Should().BeEquivalentTo(expectedTranslation); }
public void TestTranslate_OnEscapedClosingSortTagInsideItalicTag() { const string expectedTranslation = @"<em>a b_</em>"; var tree = treeBuilder .WithTag(TestTreeBuilder .Tag(new ItalicTagInfo()) .WithText("a") .WithSpace() .WithText("b") .WithText("_") .Build()) .Build(); var translation = treeTranslator.Translate(tree); translation.Should().BeEquivalentTo(expectedTranslation); }
public void TestBuildTree_OnHeading6WithText() { var tokens = new[] { new Token(TokenType.Tag, "###### "), new Token(TokenType.Text, "a"), new Token(TokenType.Tag, "\n") }; var expectedTree = testTreeBuilder .WithTag(TestTreeBuilder .Tag(new H6TagInfo()) .WithText("a") .Build()) .Build(); var tree = builder.BuildTree(tokens); tree.Should().BeEquivalentTo(expectedTree); }
public void TestTranslate_OnOuterTagClosedBeforeInner() { const string expectedTranslation = "<strong>a _b</strong> c_"; var tree = treeBuilder .WithTag(TestTreeBuilder .Tag(new BoldTagInfo()) .WithText("a") .WithSpace() .WithText("_") .WithText("b") .Build()) .WithSpace() .WithText("c") .WithText("_") .Build(); var translation = treeTranslator.Translate(tree); translation.Should().BeEquivalentTo(expectedTranslation); }
public void TestTranslate_OnItalicTagInsideBoldTag() { const string expectedTranslation = "<strong>a <em>b</em> c</strong>"; var tree = treeBuilder .WithTag(TestTreeBuilder .Tag(new BoldTagInfo()) .WithText("a") .WithSpace() .WithTag(TestTreeBuilder .Tag(new ItalicTagInfo()) .WithText("b") .Build()) .WithSpace() .WithText("c") .Build()) .Build(); var translation = treeTranslator.Translate(tree); translation.Should().BeEquivalentTo(expectedTranslation); }
public void SetUp() { tagsInfo = new MarkdownLanguage().GetTagsInfo; builder = new MarkdownTokenTreeBuilder(tagsInfo); testTreeBuilder = TestTreeBuilder.Tree(); }