public void CanRenderEmptyDocument() { var document = new MobileDocBuilder() .Build(); var renderer = new MobileDocRenderer(new CardRenderer[] { }, new AtomRenderer[] { }); var output = renderer.Render(document); output.Should().Be("<article></article>"); }
public void CanRenderImageSections() { var document = new MobileDocBuilder() .WithImageSection(section => section .WithUrl("http://www.google.nl/images/test.png")) .Build(); var renderer = new MobileDocRenderer(new CardRenderer[] { }, new AtomRenderer[] { }); var output = renderer.Render(document); output.Should().Be("<article><img src=\"http://www.google.nl/images/test.png\"></article>"); }
public void CanRenderSimpleDocument() { var document = new MobileDocBuilder() .WithMarkupSection(section => section .WithMarkupMarker(new int[] { }, 0, "Hello world") .WithTagName("p")) .Build(); var renderer = new MobileDocRenderer(new CardRenderer[] { }, new AtomRenderer[] { }); var output = renderer.Render(document); output.Should().Be("<article><p>Hello world</p></article>"); }
public void CanParseImageSections() { var document = new MobileDocBuilder() .WithImageSection(section => section .WithUrl("/images/image.png")) .Build(); var parser = new MobileDocParser(MobileDocSerializer.Serialize(document)); var result = parser.MobileDoc(); result.Sections.Should().ContainSingle(x => x.SectionType == SectionTypes.Image); result.Sections.First().As <ImageSection>().Url.Should().Be("/images/image.png"); }
public void CanParseDocumentWithoutMarkups() { var document = new MobileDocBuilder() .WithMarkupSection(section => section .WithTagName("p") .WithMarkupMarker(new int[] { }, 0, "hello world")) .Build(); var parser = new MobileDocParser(MobileDocSerializer.Serialize(document)); var result = parser.MobileDoc(); result.Sections.Should().ContainSingle(x => x.SectionType == 1); }
public void CanRenderCardSection() { var document = new MobileDocBuilder() .WithCard(card => card.WithName("test").WithPayload(new JObject())) .WithCardSection(section => section.WithCardIndex(0)) .Build(); var renderer = new MobileDocRenderer(new CardRenderer[] { new CodeCardRenderer() }, new AtomRenderer[] { }); var output = renderer.Render(document); output.Should().Be("<article><div class=\"code\"></div></article>"); }
public void CanRenderListSectionWithoutMarkup() { var document = new MobileDocBuilder() .WithListSection(section => section .WithListType("ul") .WithAttribute("class", "test") .WithListItem(item => item .WithMarkupMarker(new int[] { }, 0, "Hello world"))) .Build(); var renderer = new MobileDocRenderer(new CardRenderer[] { }, new AtomRenderer[] { }); var output = renderer.Render(document); output.Should().Be("<article><ul class=\"test\"><li>Hello world</li></ul></article>"); }
public void CanParseMarkupSectionAttributes() { var document = new MobileDocBuilder() .WithMarkupSection(section => section .WithTagName("pull-quote") .WithMarkupMarker(new int[] { }, 0, "Hello world") .WithAttribute("data-test", "test")) .Build(); var parser = new MobileDocParser(MobileDocSerializer.Serialize(document)); var result = parser.MobileDoc(); result.Sections.FirstOrDefault()?.As <MarkupSection>().Attributes.Should() .Contain(x => x.Name == "data-test" && x.Value == "test"); }
public void CanParseCardSections() { var document = new MobileDocBuilder() .WithCard(card => card .WithName("markdown") .WithPayload(JObject.FromObject(new { text = "# Heading 1" }))) .WithCardSection(section => section.WithCardIndex(0)) .Build(); var parser = new MobileDocParser(MobileDocSerializer.Serialize(document)); var result = parser.MobileDoc(); result.Cards.Should().NotBeEmpty(); result.Cards.First().Name.Should().Be("markdown"); }
public void CanRenderWithMarkup() { var document = new MobileDocBuilder() .WithMarkup(markup => markup .WithTagName("b") .WithAttribute("class", "very-bold")) .WithMarkupSection(section => section .WithTagName("p") .WithMarkupMarker(new int[] { 0 }, 1, "Hello world")) .Build(); var renderer = new MobileDocRenderer(new CardRenderer[] { }, new AtomRenderer[] { }); var output = renderer.Render(document); output.Should().Be("<article><p><b class=\"very-bold\">Hello world</b></p></article>"); }
public void CanParseMarkers() { var document = new MobileDocBuilder() .WithMarkupSection(section => section .WithTagName("pull-quote") .WithMarkupMarker(new int[] { }, 0, "Hello world") .WithAttribute("data-test", "test")) .Build(); var parser = new MobileDocParser(MobileDocSerializer.Serialize(document)); var result = parser.MobileDoc(); result.Sections.First().As <MarkupSection>().Markers.First().As <MarkupMarker>().Text.Should() .Be("Hello world"); result.Sections.First().As <MarkupSection>().Markers.First().OpenMarkupIndices.Should().BeEmpty(); result.Sections.First().As <MarkupSection>().Markers.First().ClosedMarkups.Should().Be(0); }
public void CanParseListSections() { var document = new MobileDocBuilder() .WithListSection(section => section .WithListType("ol") .WithListItem(item => item .WithMarkupMarker(new int[] { }, 0, "Item 1") .WithAtomMarker(new int[] { }, 0, 0)) .WithAttribute("class", "test")) .Build(); var parser = new MobileDocParser(MobileDocSerializer.Serialize(document)); var result = parser.MobileDoc(); result.Sections.Should().ContainSingle(x => x.SectionType == SectionTypes.List); result.Sections.First().As <ListSection>().ListItems.Should().NotBeEmpty(); }
public void CanParseMarkups() { var document = new MobileDocBuilder() .WithMarkup(markup => markup.WithTagName("a").WithAttribute("href", "https://google.nl")) .WithMarkupSection(section => section .WithTagName("p") .WithMarkupMarker(new int[] { 0 }, 1, "Test link")) .Build(); var parser = new MobileDocParser(MobileDocSerializer.Serialize(document)); var result = parser.MobileDoc(); result.Markups.Should().NotBeEmpty(); result.Markups.First().Name.Should().Be("a"); result.Markups.First().Attributes.Should().Contain( x => x.Name == "href" && x.Value == "https://google.nl"); }
public void CanRenderWithMissingAtomRenderer() { var document = new MobileDocBuilder() .WithMarkup(markup => markup .WithTagName("b") .WithAttribute("class", "very-bold")) .WithAtom(atom => atom.WithName("test").WithText("test").WithPayload(new JObject())) .WithMarkupSection(section => section .WithTagName("p") .WithMarkupMarker(new int[] { 0 }, 1, "Hello") .WithAtomMarker(new int[] { }, 0, 0)) .Build(); var renderer = new MobileDocRenderer(new CardRenderer[] { }, new AtomRenderer[] { }); var output = renderer.Render(document); output.Should().Be("<article><p><b class=\"very-bold\">Hello</b></p></article>"); }
public void CanRenderWithPartiallyClosedMarkup() { var document = new MobileDocBuilder() .WithMarkup(markup => markup .WithTagName("h1")) .WithMarkup(markup => markup .WithTagName("b")) .WithMarkupSection(section => section .WithTagName("p") .WithMarkupMarker(new int[] { 0 }, 0, "Hello ") .WithMarkupMarker(new int[] { 1 }, 2, "world")) .Build(); var renderer = new MobileDocRenderer(new CardRenderer[] { }, new AtomRenderer[] { }); var output = renderer.Render(document); output.Should().Be("<article><p><h1>Hello <b>world</b></h1></p></article>"); }
public void CanParseAtoms() { var document = new MobileDocBuilder() .WithAtom(atom => atom .WithName("test") .WithText("Awesomeness") .WithPayload(new JObject(new JProperty("test", "test")))) .WithMarkupSection(section => section .WithTagName("pull-quote") .WithAtomMarker(new int[] { }, 0, 0) .WithAttribute("data-test", "test")) .Build(); var parser = new MobileDocParser(MobileDocSerializer.Serialize(document)); var result = parser.MobileDoc(); result.Atoms.Should().ContainSingle(); result.Atoms.First().Name.Should().Be("test"); result.Atoms.First().Text.Should().Be("Awesomeness"); result.Atoms.First().Payload["test"].Value <string>().Should().Be("test"); }