Append() public method

public Append ( string unencoded ) : IHtmlContentBuilder
unencoded string
return IHtmlContentBuilder
Exemplo n.º 1
0
        public void HtmlFormattableString_WithOtherIHtmlContent()
        {
            // Arrange
            var builder = new HtmlContentBuilder();

            builder.Append("First");

            var formattableString = new HtmlFormattableString("{0}!", builder);

            // Act
            var result = HtmlContentToString(formattableString);

            // Assert
            Assert.Equal("HtmlEncode[[First]]!", result);
        }
Exemplo n.º 2
0
        public void CopyTo_CopiesAllItems()
        {
            // Arrange
            var source = new DefaultTagHelperContent();
            source.AppendHtml(new HtmlEncodedString("hello"));
            source.Append("Test");

            var items = new List<object>();
            var destination = new HtmlContentBuilder(items);
            destination.Append("some-content");

            // Act
            source.CopyTo(destination);

            // Assert
            Assert.Equal(3, items.Count);

            Assert.Equal("some-content", Assert.IsType<string>(items[0]));
            Assert.Equal("hello", Assert.IsType<HtmlEncodedString>(items[1]).Value);
            Assert.Equal("Test", Assert.IsType<string>(items[2]));
        }
Exemplo n.º 3
0
        public void MoveTo_DoesDeepMove()
        {
            // Arrange
            var source = new DefaultTagHelperContent();

            var nested = new DefaultTagHelperContent();
            source.AppendHtml(nested);
            nested.AppendHtml(new HtmlEncodedString("hello"));
            source.Append("Test");

            var items = new List<object>();
            var destination = new HtmlContentBuilder(items);
            destination.Append("some-content");

            // Act
            source.MoveTo(destination);

            // Assert
            Assert.Equal(string.Empty, source.GetContent());
            Assert.Equal(string.Empty, nested.GetContent());
            Assert.Equal(3, items.Count);

            Assert.Equal("some-content", Assert.IsType<string>(items[0]));
            Assert.Equal("hello", Assert.IsType<HtmlEncodedString>(items[1]).Value);
            Assert.Equal("Test", Assert.IsType<string>(items[2]));
        }
        public void HtmlFormattableString_WithOtherIHtmlContent()
        {
            // Arrange
            var builder = new HtmlContentBuilder();
            builder.Append("First");

            var formattableString = new HtmlFormattableString("{0}!", builder);

            // Act
            var result = HtmlContentToString(formattableString);

            // Assert
            Assert.Equal("HtmlEncode[[First]]!", result);
        }