예제 #1
0
        public void Container_CanContainText_AddMultipleTextContent_Works(Fb2Container node)
        {
            node.Should().NotBeNull();

            if (!node.CanContainText)
            {
                return;
            }

            node.AddTextContent("test text");

            node.Content.Count.Should().Be(1);
            var first = node.GetFirstChild <TextItem>();

            first.Should().NotBeNull();
            first.Content.Should().Be("test text");

            node.AddTextContent("test text 2", " ");

            node.Content.Count.Should().Be(1);
            var second = node.GetFirstChild <TextItem>();

            second.Should().NotBeNull();
            second.Content.Should().Be("test text test text 2");
            first.Content.Should().Be("test text test text 2");

            node.AddTextContent("test text 3", " ");

            node.Content.Count.Should().Be(1);
            second.Content.Should().Be("test text test text 2 test text 3");
            first.Content.Should().Be("test text test text 2 test text 3");
        }
예제 #2
0
        public void Container_CanContainText_AddTextContent_Works(Fb2Container node)
        {
            node.Should().NotBeNull();

            if (!node.CanContainText)
            {
                return;
            }

            node.AddContent(new TextItem().AddContent("test text"));

            node.Content.Count.Should().Be(1);
            var first = node.Content.First();

            first.Should().BeOfType(typeof(TextItem));
            (first as Fb2Element).Content.Should().Be("test text");

            ClearContainerContent(node);

            node.AddTextContent("test text");

            node.Content.Count.Should().Be(1);
            var second = node.Content.First();

            second.Should().BeOfType(typeof(TextItem));
            (second as Fb2Element).Content.Should().Be("test text");

            ClearContainerContent(node);
        }
예제 #3
0
        public void Container_CanContainText_AddMultipleTextContent_WithContainers_Works(Fb2Container node)
        {
            node.Should().NotBeNull();

            if (!node.CanContainText)
            {
                return;
            }

            node.AddTextContent("test text");

            node.Content.Count.Should().Be(1);
            var first = node.GetFirstChild <TextItem>();

            first.Should().NotBeNull();
            first.Content.Should().Be("test text");

            node.AddTextContent("test text 2", "  ");

            node.Content.Count.Should().Be(1);
            var second = node.GetFirstChild <TextItem>();

            second.Should().NotBeNull();
            second.Content.Should().Be("test text  test text 2");
            first.Content.Should().Be("test text  test text 2");

            node.AddContent(node.AllowedElements.First());
            node.Content.Count.Should().Be(2);

            node.AddTextContent("test text 3", " ");
            node.Content.Count.Should().Be(3);
            var textItems = node.GetChildren <TextItem>().ToList();

            textItems.Count.Should().Be(2);
            textItems.First().Content.Should().Be("test text  test text 2");
            textItems.Last().Content.Should().Be(" test text 3");
        }