From 22d0d36a3e212b5af7fa0fc063e2a96ee5804dfb Mon Sep 17 00:00:00 2001 From: Mark Gibbons Date: Fri, 28 Feb 2020 11:36:19 +1000 Subject: [PATCH] Add PngQuantCliOptimizerTests --- src/Dianoga.Tests/Dianoga.Tests.csproj | 1 + .../DianogaPng/PngQuantCliOptimizerTests.cs | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 src/Dianoga.Tests/Optimizers/Pipelines/DianogaPng/PngQuantCliOptimizerTests.cs diff --git a/src/Dianoga.Tests/Dianoga.Tests.csproj b/src/Dianoga.Tests/Dianoga.Tests.csproj index bffa65ec..4ac399ea 100644 --- a/src/Dianoga.Tests/Dianoga.Tests.csproj +++ b/src/Dianoga.Tests/Dianoga.Tests.csproj @@ -43,6 +43,7 @@ + diff --git a/src/Dianoga.Tests/Optimizers/Pipelines/DianogaPng/PngQuantCliOptimizerTests.cs b/src/Dianoga.Tests/Optimizers/Pipelines/DianogaPng/PngQuantCliOptimizerTests.cs new file mode 100644 index 00000000..0582aff2 --- /dev/null +++ b/src/Dianoga.Tests/Optimizers/Pipelines/DianogaPng/PngQuantCliOptimizerTests.cs @@ -0,0 +1,34 @@ +using System.IO; +using Dianoga.Optimizers; +using Dianoga.Optimizers.Pipelines.DianogaPng; +using FluentAssertions; +using Xunit; + +namespace Dianoga.Tests.Optimizers.Pipelines.DianogaPng +{ + public class PngQuantCliOptimizerTests + { + [Fact] + public void ShouldSquishTestPng() + { + var inputStream = new MemoryStream(); + + using (var testPng = File.OpenRead(@"Optimizers\Pipelines\DianogaPng\test.png")) + { + testPng.CopyTo(inputStream); + } + + var sut = new PngQuantCliOptimizer(); + sut.ExePath = @"..\..\..\Dianoga\Dianoga Tools\pngquant\pngquant.exe"; + + var args = new OptimizerArgs(inputStream); + + var startingSize = args.Stream.Length; + + sut.Process(args); + + args.Stream.Length.Should().BeLessThan(startingSize).And.BeGreaterThan(0); + args.IsOptimized.Should().BeTrue(); + } + } +}