public void RemoveSelectors()
 {
     this.hacks.Add("foo");
     MinificationVerifier.VerifyMinification(BaseDirectory, "RemoveSelectors.css", new List <NodeVisitor> {
         new SelectorValidationOptimizationVisitor(this.hacks, false, false)
     });
     PrettyPrintVerifier.VerifyPrettyPrint(BaseDirectory, "RemoveSelectors.css", new List <NodeVisitor> {
         new SelectorValidationOptimizationVisitor(this.hacks, false, false)
     });
 }
Example #2
0
        public void ExcludeByKeysTest()
        {
            const string FileName       = @"excludebykeys.css";
            var          styleSheetNode = CssParser.Parse(new FileInfo(Path.Combine(ActualDirectory, FileName)));

            Assert.IsNotNull(styleSheetNode);
            MinificationVerifier.VerifyMinification(BaseDirectory, FileName, new List <NodeVisitor> {
                new ExcludePropertyVisitor()
            });
            PrettyPrintVerifier.VerifyPrettyPrint(BaseDirectory, FileName, new List <NodeVisitor> {
                new ExcludePropertyVisitor()
            });
        }
Example #3
0
        public void OptimizeBorder()
        {
            const string FileName       = @"border.css";
            var          styleSheetNode = CssParser.Parse(new FileInfo(Path.Combine(ActualDirectory, FileName)));

            Assert.IsNotNull(styleSheetNode);
            MinificationVerifier.VerifyMinification(BaseDirectory, FileName, new List <NodeVisitor> {
                new OptimizationVisitor()
            });
            PrettyPrintVerifier.VerifyPrettyPrint(BaseDirectory, FileName, new List <NodeVisitor> {
                new OptimizationVisitor()
            });
        }
Example #4
0
        public void ShouldNotOptimizeFontface()
        {
            const string FileName       = @"fontface.css";
            var          styleSheetNode = CssParser.Parse(new FileInfo(Path.Combine(ActualDirectory, FileName)));

            Assert.IsNotNull(styleSheetNode);
            MinificationVerifier.VerifyMinification(BaseDirectory, FileName, new List <NodeVisitor> {
                new OptimizationVisitor {
                    NonMergeRuleSetSelectors = new[] { "@font-face" }
                }
            });
            PrettyPrintVerifier.VerifyPrettyPrint(BaseDirectory, FileName, new List <NodeVisitor> {
                new OptimizationVisitor {
                    NonMergeRuleSetSelectors = new[] { "@font-face" }
                }
            });
        }
        public void RgbCollapse()
        {
            const string FileName       = @"RgbCollapse.css";
            AstNode      styleSheetNode = CssParser.Parse(new FileInfo(Path.Combine(ActualDirectory, FileName)));

            Assert.IsNotNull(styleSheetNode);

            styleSheetNode = styleSheetNode.Accept(new ColorOptimizationVisitor());
            Assert.IsNotNull(styleSheetNode);

            MinificationVerifier.VerifyMinification(BaseDirectory, FileName, new List <NodeVisitor> {
                new ColorOptimizationVisitor()
            });
            PrettyPrintVerifier.VerifyPrettyPrint(BaseDirectory, FileName, new List <NodeVisitor> {
                new ColorOptimizationVisitor()
            });
        }
        public void ImageUpdateVisitorShorthandDeclarationsTest()
        {
            const string FileName = @"imageupdatevisitorshorthanddeclarations.css";
            var          fileInfo = new FileInfo(Path.Combine(ActualDirectory, FileName));

            var styleSheetNode = CssParser.Parse(fileInfo);

            Assert.IsNotNull(styleSheetNode);

            var visitor = CreateVisitor(fileInfo.FullName);

            styleSheetNode = styleSheetNode.Accept(visitor) as StyleSheetNode;
            Assert.IsNotNull(styleSheetNode);

            MinificationVerifier.VerifyMinification(BaseDirectory, FileName, new List <NodeVisitor> {
                visitor
            });
            PrettyPrintVerifier.VerifyPrettyPrint(BaseDirectory, FileName, new List <NodeVisitor> {
                visitor
            });
        }
        public void ImageUpdateVisitorRemTest()
        {
            const string FileName = @"imageupdatevisitorrem.css";
            var          fileInfo = new FileInfo(Path.Combine(ActualDirectory, FileName));

            var styleSheetNode = CssParser.Parse(fileInfo);

            Assert.IsNotNull(styleSheetNode);

            // use 2X DPI, REM units, and scale the number by 1/10.
            var visitor = CreateVisitor(fileInfo.FullName, 2f, ImageAssembleConstants.Rem, 0.1);

            styleSheetNode = styleSheetNode.Accept(visitor) as StyleSheetNode;
            Assert.IsNotNull(styleSheetNode);

            MinificationVerifier.VerifyMinification(BaseDirectory, FileName, new List <NodeVisitor> {
                visitor
            });
            PrettyPrintVerifier.VerifyPrettyPrint(BaseDirectory, FileName, new List <NodeVisitor> {
                visitor
            });
        }