示例#1
0
            public void MinifyWithCustomSettings()
            {
                // Given
                string input  = @"<html>
                        <head>
                            <title>Title</title>
                        </head>
                        <body>
                            <!-- FOO -->
                            <h1>Title</h1>
                            <p>This is<br />some text</p>
                        </body>
                    </html>";
                string output = @"<html><head><title>Title</title></head><body><!-- FOO --><h1>Title</h1><p>This is<br>some text</p></body></html>";
                TestExecutionContext context    = new TestExecutionContext();
                TestDocument         document   = new TestDocument(input);
                MinifyHtml           minifyHtml = new MinifyHtml()
                                                  .WithSettings(settings =>
                {
                    settings.RemoveOptionalEndTags = false;
                    settings.RemoveHtmlComments    = false;
                });

                // When
                IList <IDocument> results = minifyHtml.Execute(new[] { document }, context).ToList();  // Make sure to materialize the result list

                // Then
                results.Single().Content.ShouldBe(output, StringCompareShould.IgnoreLineEndings);
            }
示例#2
0
            public void MinifyWithCustomSettings()
            {
                // Given
                string input = @"<html>
                        <head>
                            <title>Title</title>
                        </head>
                        <body>
                            <!-- FOO -->
                            <h1>Title</h1>
                            <p>This is<br />some text</p>
                        </body>
                    </html>";
                string output = @"<html><head><title>Title</title></head><body><!-- FOO --><h1>Title</h1><p>This is<br>some text</p></body></html>";

                IExecutionContext context = Substitute.For<IExecutionContext>();
                IDocument document = Substitute.For<IDocument>();
                document.Content.Returns(input);

                MinifyHtml minifyHtml = new MinifyHtml()
                    .WithSettings(settings =>
                    {
                        settings.RemoveOptionalEndTags = false;
                        settings.RemoveHtmlComments = false;
                    });

                // When
                minifyHtml.Execute(new[] { document }, context).ToList();  // Make sure to materialize the result list

                // Then
                context.Received(1).GetDocument(Arg.Any<IDocument>(), Arg.Any<string>());
                context.Received().GetDocument(document, output);
            }
            public async Task MinifyWithCustomSettings()
            {
                // Given
                const string input      = @"<html>
                        <head>
                            <title>Title</title>
                        </head>
                        <body>
                            <!-- FOO -->
                            <h1>Title</h1>
                            <p>This is<br />some text</p>
                        </body>
                    </html>";
                const string output     = "<html><head><title>Title</title></head><body><!-- FOO --><h1>Title</h1><p>This is<br>some text</p></body></html>";
                TestDocument document   = new TestDocument(input);
                MinifyHtml   minifyHtml = new MinifyHtml()
                                          .WithSettings(settings =>
                {
                    settings.RemoveOptionalEndTags = false;
                    settings.RemoveHtmlComments    = false;
                });

                // When
                TestDocument result = await ExecuteAsync(document, minifyHtml).SingleAsync();

                // Then
                result.Content.ShouldBe(output, StringCompareShould.IgnoreLineEndings);
            }
示例#4
0
            public void MinifyWithCustomSettings()
            {
                // Given
                string input  = @"<html>
                        <head>
                            <title>Title</title>
                        </head>
                        <body>
                            <!-- FOO -->
                            <h1>Title</h1>
                            <p>This is<br />some text</p>
                        </body>
                    </html>";
                string output = @"<html><head><title>Title</title></head><body><!-- FOO --><h1>Title</h1><p>This is<br>some text</p></body></html>";

                IExecutionContext context  = Substitute.For <IExecutionContext>();
                IDocument         document = Substitute.For <IDocument>();

                document.Content.Returns(input);

                MinifyHtml minifyHtml = new MinifyHtml()
                                        .WithSettings(settings =>
                {
                    settings.RemoveOptionalEndTags = false;
                    settings.RemoveHtmlComments    = false;
                });

                // When
                minifyHtml.Execute(new[] { document }, context).ToList();  // Make sure to materialize the result list

                // Then
                context.Received(1).GetDocument(Arg.Any <IDocument>(), Arg.Any <string>());
                context.Received().GetDocument(document, output);
            }
示例#5
0
            public void MinifyWithCustomSettings()
            {
                // Given
                string input  = @"<html>
                        <head>
                            <title>Title</title>
                        </head>
                        <body>
                            <!-- FOO -->
                            <h1>Title</h1>
                            <p>This is<br />some text</p>
                        </body>
                    </html>";
                string output = @"<html><head><title>Title</title></head><body><!-- FOO --><h1>Title</h1><p>This is<br>some text</p></body></html>";
                TestExecutionContext context    = new TestExecutionContext();
                TestDocument         document   = new TestDocument(input);
                MinifyHtml           minifyHtml = new MinifyHtml()
                                                  .WithSettings(settings =>
                {
                    settings.RemoveOptionalEndTags = false;
                    settings.RemoveHtmlComments    = false;
                });

                // When
                IList <IDocument> results = minifyHtml.Execute(new[] { document }, context).ToList();  // Make sure to materialize the result list

                // Then
                Assert.That(results.Select(x => x.Content), Is.EquivalentTo(new[] { output }));
            }
            public async Task Minify()
            {
                // Given
                const string input      = @"<html>
                        <head>
                            <title>Title</title>
                        </head>
                        <body>
                            <!-- FOO -->
                            <h1>Title</h1>
                            <p>This is<br />some text</p>
                        </body>
                    </html>";
                const string output     = "<html><head><title>Title</title><body><h1>Title</h1><p>This is<br>some text";
                TestDocument document   = new TestDocument(input);
                MinifyHtml   minifyHtml = new MinifyHtml();

                // When
                TestDocument result = await ExecuteAsync(document, minifyHtml).SingleAsync();

                // Then
                result.Content.ShouldBe(output, StringCompareShould.IgnoreLineEndings);
            }
示例#7
0
            public void Minify()
            {
                // Given
                const string         input      = @"<html>
                        <head>
                            <title>Title</title>
                        </head>
                        <body>
                            <!-- FOO -->
                            <h1>Title</h1>
                            <p>This is<br />some text</p>
                        </body>
                    </html>";
                const string         output     = "<html><head><title>Title</title><body><h1>Title</h1><p>This is<br>some text";
                TestExecutionContext context    = new TestExecutionContext();
                TestDocument         document   = new TestDocument(input);
                MinifyHtml           minifyHtml = new MinifyHtml();

                // When
                IList <IDocument> results = minifyHtml.Execute(new[] { document }, context).ToList();  // Make sure to materialize the result list

                // Then
                results.Single().Content.ShouldBe(output, StringCompareShould.IgnoreLineEndings);
            }