예제 #1
0
        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");
        }
예제 #2
0
        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);
        }
예제 #3
0
        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");
        }
예제 #4
0
        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");
        }
예제 #5
0
        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);
        }
예제 #6
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();
        }
예제 #7
0
        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");
        }
예제 #8
0
        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");
        }