public void Minify() { // Given // Example taken from http://yui.github.io/yuicompressor/css.html string input = @" /***** Multi-line comment before a new class name *****/ .classname { /* comment in declaration block */ font-weight: normal; }"; string output = @".classname{font-weight:normal}"; IExecutionContext context = Substitute.For <IExecutionContext>(); IDocument document = Substitute.For <IDocument>(); document.Content.Returns(input); MinifyCss minifyCss = new MinifyCss(); // When minifyCss.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 void Minify() { // Given // Example taken from http://yui.github.io/yuicompressor/css.html string input = @" /***** Multi-line comment before a new class name *****/ .classname { /* comment in declaration block */ font-weight: normal; }"; string output = @".classname{font-weight:normal}"; IExecutionContext context = Substitute.For<IExecutionContext>(); IDocument document = Substitute.For<IDocument>(); document.Content.Returns(input); MinifyCss minifyCss = new MinifyCss(); // When minifyCss.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); }
protected override void OnPreRender(EventArgs e) { bool isIe = HttpContext.Current.Request.Browser.Browser.Trim() .Equals("IE", StringComparison.InvariantCultureIgnoreCase); int ieVersion = isIe ? HttpContext.Current.Request.Browser.MajorVersion : 0; ICombinerService myCombiner = CombinerServiceFactory.CreateCombinerService(); var logger = new LoggingService.LoggingService(); HttpContext.Current.Response.Filter = new CombinerResponseStream( HttpContext.Current.Response.Filter, CombinerLiveSettings.CombineJs && CombineJs.GetValueOrDefault(true), CombinerLiveSettings.CombineCss && CombineCss.GetValueOrDefault(true), CombinerLiveSettings.MinifyJs && MinifyJs.GetValueOrDefault(true), CombinerLiveSettings.MinifyCss && MinifyCss.GetValueOrDefault(true), CombinerLiveSettings.VersionOnly && VersionOnly.GetValueOrDefault(true), CombinerLiveSettings.PrependCdnHostToImages && PrependCdnHostToImages.GetValueOrDefault(true), CombinerLiveSettings.JsVersion, CombinerLiveSettings.CssVersion, CombinerConstantsAndSettings.JsAndCssSharedVersion, ieVersion, HttpContext.Current.Request.Url.AbsolutePath, myCombiner, logger, CombinerConstantsAndSettings.WebSettings.ComboScriptUrl, CombinerConstantsAndSettings.WebSettings.ImagesCdnHostToPrepend ); if (ApplyOutputCaching.GetValueOrDefault(true)) { // Set cacheability HttpContext.Current.Response.Cache.SetExpires(DateTime.Now.AddMonths(1)); HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.Public); HttpContext.Current.Response.Cache.SetValidUntilExpires(true); HttpContext.Current.Response.Cache.VaryByParams["*"] = true; // Set file dependency for output cache // when the live.js is updated we need to invalidate the OutputCache for this page string path = CombinerConstantsAndSettings.WebSettings.CombinerLiveSettingsFile; string liveSettingsFilePath = HttpContext.Current.Server.MapPath(path); HttpContext.Current.Response.AddFileDependency(liveSettingsFilePath); } }
public async Task Minify() { // Given // Example taken from http://yui.github.io/yuicompressor/css.html const string input = @" /***** Multi-line comment before a new class name *****/ .classname { /* comment in declaration block */ font-weight: normal; }"; const string output = ".classname{font-weight:normal}"; TestDocument document = new TestDocument(input); MinifyCss minifyCss = new MinifyCss(); // When TestDocument result = await ExecuteAsync(document, minifyCss).SingleAsync(); // Then result.Content.ShouldBe(output, StringCompareShould.IgnoreLineEndings); }
public void Minify() { // Given // Example taken from http://yui.github.io/yuicompressor/css.html string input = @" /***** Multi-line comment before a new class name *****/ .classname { /* comment in declaration block */ font-weight: normal; }"; string output = @".classname{font-weight:normal}"; TestExecutionContext context = new TestExecutionContext(); TestDocument document = new TestDocument(input); MinifyCss minifyCss = new MinifyCss(); // When IList <IDocument> results = minifyCss.Execute(new[] { document }, context).ToList(); // Make sure to materialize the result list // Then results.Single().Content.ShouldBe(output, StringCompareShould.IgnoreLineEndings); }
public void Minify() { // Given // Example taken from http://yui.github.io/yuicompressor/css.html string input = @" /***** Multi-line comment before a new class name *****/ .classname { /* comment in declaration block */ font-weight: normal; }"; string output = @".classname{font-weight:normal}"; TestExecutionContext context = new TestExecutionContext(); TestDocument document = new TestDocument(input); MinifyCss minifyCss = new MinifyCss(); // When IList <IDocument> results = minifyCss.Execute(new[] { document }, context).ToList(); // Make sure to materialize the result list // Then Assert.That(results.Select(x => x.Content), Is.EquivalentTo(new[] { output })); }