public void Should_Combine_Files_To_Output_Path() { var filepath1 = @"c:\css\style.css"; var filepath2 = @"c:\css\style2.css"; var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData> { { filepath1, new MockFileData("a { color: Red; }") }, { filepath2, new MockFileData("a { color: Blue; }") } }); var files = new List<FileInfo> { new FileInfo(filepath1), new FileInfo(filepath2) }; var factory = new TestContainerFactory(); var engine = factory.GetEngine(fileSystem, @"c:\css"); var minifier = new CssMinifier(fileSystem, files, _outputPath, () => engine); minifier.Minify(); var expectedOutput = @"a{color:Red}a{color:Blue}"; var minifiedFile = fileSystem.File.ReadAllText(_outputPath, Encoding.UTF8); Assert.Equal(expectedOutput, minifiedFile); }
public void Should_Compile_Less_To_Css_To_Output_Path() { var lessContent = @"@brand_color: #4D926F; #header { color: @brand_color; } h2 { color: @brand_color; }"; var lessOutput = @"#header{color:#4d926f}h2{color:#4d926f}"; var filepath = @"c:\css\style.less"; var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData> { { filepath, new MockFileData(lessContent) } }); var files = new List<FileInfo>() { new FileInfo(filepath) }; var factory = new TestContainerFactory(); var engine = factory.GetEngine(fileSystem, @"c:\css"); var minifier = new CssMinifier(fileSystem, files, _outputPath, () => engine); minifier.Minify(); var minifiedFile = fileSystem.File.ReadAllText(_outputPath, Encoding.UTF8); Assert.Equal(lessOutput, minifiedFile); }
private string minifyCss(string templateContent) { var outputPath = Path.Combine(_siteDirectory, @"_site\css\minified.css"); //todo extract all internal css/less links from template var cssFiles = new List<FileInfo>(); var cssMinifier = new CssMinifier(_fileSystem, cssFiles, outputPath); cssMinifier.Minify(); //todo replace extracted links with single link to minified css (possibly with a hash appended) throw new NotImplementedException(); }
public void Should_Write_Single_File_To_Output_Path() { var filepath = @"c:\css\style.css"; var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData> { { filepath, new MockFileData("a { color: Red; }") } }); var files = new List<FileInfo>() { new FileInfo(filepath) }; var factory = new TestContainerFactory(); var engine = factory.GetEngine(fileSystem, @"c:\css"); var minifier = new CssMinifier(fileSystem, files, _outputPath, () => engine); minifier.Minify(); var minifiedFile = fileSystem.File.ReadAllText(_outputPath, Encoding.UTF8); Assert.False(string.IsNullOrWhiteSpace(minifiedFile)); }