Esempio n. 1
0
        public void Should_Process_Less_Imports()
        {
            var filepath1 = @"c:\css\style.less";
            var filepath2 = @"c:\css\style2.less";

            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
            {
                { filepath1, new MockFileData("@brand_color: #4D926F;") },
                { filepath2, new MockFileData("@import \"style.less\"; a { color: @brand_color; }") }
            });

            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);

            var expectedOutput = @"a{color:#4d926f}";

            var minifiedFile = minifier.ProcessCss(new FileInfo(filepath2));

            Assert.Equal(expectedOutput, minifiedFile);
        }
Esempio n. 2
0
        public void Should_Compile_Single_Less_File()
        {
            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);
            var minified = minifier.ProcessCss(new FileInfo(filepath));

            Assert.Equal(lessOutput, minified);
        }
Esempio n. 3
0
        public void Should_Minify_Single_File()
        {
            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);

            var result = minifier.ProcessCss(new FileInfo(filepath));

            Assert.Equal("a{color:Red}", result);
        }