예제 #1
0
        public void QuantizationWillMakeOriginalPngSmaller()
        {
            var config    = new Mock <IRRConfiguration>();
            var optimizer = new PngOptimizer(new FileWrapper(), config.Object, new WuQuantizer());
            var original  = File.ReadAllBytes("testimages\\menu-sprite.png");

            var result = optimizer.OptimizePng(original, 0, false);

            Assert.True(result.Length < original.Length);
        }
예제 #2
0
        public void WillNotAlterOriginalImage()
        {
            var config = new Mock <IRRConfiguration>();

            config.Setup(x => x.ResourcePhysicalPath).Returns("testimages");
            var optimizer = new PngOptimizer(new FileWrapper(), config.Object, new WuQuantizer());
            var original  = File.ReadAllBytes("testimages\\menu-sprite.png");

            optimizer.OptimizePng(original, 5, false);

            Assert.Equal(original.Length, File.ReadAllBytes("testimages\\menu-sprite.png").Length);
        }
예제 #3
0
        public void CompressionWillMakeOriginalPngSmaller()
        {
            var config = new Mock <IRRConfiguration>();

            config.Setup(x => x.ResourcePhysicalPath).Returns("testimages");
            var optimizer = new PngOptimizer(new FileWrapper(), config.Object, new WuQuantizer());
            var original  = File.ReadAllBytes("testimages\\menu-sprite.png");

            var result = optimizer.OptimizePng(original, 5, true);

            Assert.True(result.Length < original.Length);
        }
예제 #4
0
        public void WillCleanupScratchFile()
        {
            var config = new Mock <IRRConfiguration>();

            config.Setup(x => x.ResourcePhysicalPath).Returns("testimages");
            var optimizer = new PngOptimizer(new FileWrapper(), config.Object, new WuQuantizer());
            var original  = File.ReadAllBytes("testimages\\menu-sprite.png");
            var fileCount = Directory.GetFiles("testimages").Length;

            optimizer.OptimizePng(original, 5, true);

            Assert.Equal(fileCount, Directory.GetFiles("testimages").Length);
        }