Skip to content

Commit

Permalink
Add PngQuantCliOptimizerTests
Browse files Browse the repository at this point in the history
  • Loading branch information
markgibbons25 committed Feb 28, 2020
1 parent 17d3e10 commit 22d0d36
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Dianoga.Tests/Dianoga.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="Optimizers\Pipelines\DianogaPng\PngQuantCliOptimizerTests.cs" />
<Compile Include="PathExclusionTests.cs" />
<Compile Include="Optimizers\DianogaOptimizerProcessorTests.cs" />
<Compile Include="Optimizers\Pipelines\DianogaJpeg\JpegOptimOptimizerTests.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
}

0 comments on commit 22d0d36

Please sign in to comment.