コード例 #1
0
        public void CopyTo_DoesDeepCopy()
        {
            // Arrange
            var source = new HtmlContentBuilder();

            var nested = new HtmlContentBuilder();

            source.AppendHtml(nested);
            nested.AppendHtml(new TestHtmlContent("hello"));
            source.Append("Test");

            var destination = new HtmlContentBuilder();

            destination.Append("some-content");

            // Act
            source.CopyTo(destination);

            // Assert
            Assert.Equal(2, source.Count);
            Assert.Equal(1, nested.Count);
            Assert.Equal(3, destination.Count);
            Assert.Collection(
                destination.Entries,
                entry => Assert.Equal("some-content", Assert.IsType <string>(entry)),
                entry => Assert.Equal(new TestHtmlContent("hello"), Assert.IsType <TestHtmlContent>(entry)),
                entry => Assert.Equal("Test", Assert.IsType <string>(entry)));
        }
コード例 #2
0
        public void CopyTo_CopiesAllItems()
        {
            // Arrange
            var source = new HtmlContentBuilder();

            source.AppendHtml(new TestHtmlContent("hello"));
            source.Append("Test");

            var destination = new HtmlContentBuilder();

            destination.Append("some-content");

            // Act
            source.CopyTo(destination);

            // Assert
            Assert.Equal(2, source.Entries.Count);
            Assert.Equal(3, destination.Entries.Count);

            Assert.Equal("some-content", Assert.IsType <string>(destination.Entries[0]));
            Assert.Equal(new TestHtmlContent("hello"), Assert.IsType <TestHtmlContent>(destination.Entries[1]));
            Assert.Equal("Test", Assert.IsType <string>(destination.Entries[2]));
        }