Exemplo n.º 1
0
        public void Fb2Element_AddContent_Works(Fb2Element fb2Element)
        {
            if (fb2Element is EmptyLine || fb2Element is SequenceInfo)
            {
                return;
            }

            fb2Element = fb2Element.AddContent("test content 1", "   "); // 3 whitespaces
            fb2Element.Content.Should().Be("   test content 1");

            fb2Element.ClearContent();

            fb2Element.AddContent("test content 1"); // no separator
            fb2Element.Content.Should().Be("test content 1");

            fb2Element.AddContent("test content 2", "   ");
            fb2Element.Content.Should().Be("test content 1   test content 2");

            fb2Element.AddContent("test content 3"); // no separator
            fb2Element.Content.Should().Be("test content 1   test content 2test content 3");

            fb2Element.AddContent(() => $"test {Environment.NewLine} content 4", " _blah_ ");
            fb2Element
            .Content
            .Should()
            .Be("test content 1   test content 2test content 3 _blah_ test   content 4");

            fb2Element.AddContent(() => $"test {Environment.NewLine} content 5", "  _blah_ ");
            fb2Element
            .Content
            .Should()
            .Be("test content 1   test content 2test content 3 _blah_ test   content 4  _blah_ test   content 5");
        }
Exemplo n.º 2
0
        public void Fb2Element_AddContent_EscapesSeparator(Fb2Element fb2Element)
        {
            if (fb2Element is EmptyLine || fb2Element is SequenceInfo)
            {
                return;
            }

            fb2Element.AddContent("test Value content 1", "<sep/> ");
            fb2Element.Content.Should().Be("&lt;sep/&gt; test Value content 1");

            fb2Element.ClearContent();
            fb2Element.Content.Should().BeEmpty();

            fb2Element.AddContent("testContent", @"<""sep&tv'2""> ");
            fb2Element.Content.Should().Be("&lt;&quot;sep&amp;tv&apos;2&quot;&gt; testContent");

            fb2Element.ClearContent();
            fb2Element.Content.Should().BeEmpty();

            fb2Element.AddContent("test content", $"<test Value{Environment.NewLine}content 1 ");
            fb2Element.Content.Should().Be("&lt;test Value content 1 test content");
        }
Exemplo n.º 3
0
        public void Fb2Element_AddContent_EscapesValue(Fb2Element fb2Element)
        {
            if (fb2Element is EmptyLine || fb2Element is SequenceInfo)
            {
                return;
            }

            fb2Element.AddContent("<test Value content 1");
            fb2Element.Content.Should().Be("&lt;test Value content 1");

            fb2Element.ClearContent();
            fb2Element.Content.Should().BeEmpty();

            fb2Element.AddContent(@"<""testValue&tv'2"">");
            fb2Element.Content.Should().Be("&lt;&quot;testValue&amp;tv&apos;2&quot;&gt;");

            fb2Element.ClearContent();
            fb2Element.Content.Should().BeEmpty();

            fb2Element.AddContent($"<test Value{Environment.NewLine}content 1");
            fb2Element.Content.Should().Be("&lt;test Value content 1");
        }