public void ResolveForMultipleUrlsRelative() { var resolver = new CssRelativeUrlResolver(@"c:\inetpub\wwwroot\", new Uri("http://localhost/myapp/")); string output = resolver.Resolve(@"c:\inetpub\wwwroot\content\css\main.css", @".icon1 { background-image: url(../images/test1.png) }, .icon2 { background-image: url(../images/icons/test2.png) }"); Assert.AreEqual(".icon1 { background-image: url(http://localhost/myapp/images/test1.png) }, .icon2 { background-image: url(http://localhost/myapp/images/icons/test2.png) }", output); }
public void DontResolveForNonRelative() { var resolver = new CssRelativeUrlResolver(@"c:\inetpub\wwwroot\", new Uri("http://localhost/myapp/")); string output = resolver.Resolve(@"c:\inetpub\wwwroot\content\css\main.css", ".icon { background-image: url(http://CDN/test.png) }"); Assert.AreEqual(".icon { background-image: url(http://CDN/test.png) }", output); }
/// <summary> /// Combines the content of the CSS files. /// </summary> /// <param name="combiner">The combiner.</param> /// <returns></returns> private string CombineCssFileContent(CombinerConfig combiner) { var resolver = new CssRelativeUrlResolver(AppDomain.CurrentDomain.BaseDirectory, new Uri(EngineContext.ApplicationPath + "/", UriKind.Relative)); PostProcessScript postProcess = resolver.Resolve; return(CombineFileContent(combiner.CssFiles, postProcess)); }
/// <summary> /// Combines the content of the CSS files. /// </summary> /// <param name="combiner">The combiner.</param> /// <returns></returns> private string CombineCssFileContent(CombinerConfig combiner) { var resolver = new CssRelativeUrlResolver(AppDomain.CurrentDomain.BaseDirectory, new Uri(EngineContext.ApplicationPath + "/", UriKind.Relative)); PostProcessScript postProcess = resolver.Resolve; return CombineFileContent(combiner.CssFiles, postProcess); }