Skip to content

Commit

Permalink
Flush the memory stream and improve error messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Dec 3, 2023
1 parent 8f46a96 commit fc6197f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/Magick.NET.Tests/Optimizers/ImageOptimizerTestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,15 @@ private long AssertCompress(string fileName, Func<Stream, bool> action, bool res
var before = memoryStream.Length;

var result = action(memoryStream);
memoryStream.Flush();

var after = memoryStream.Length;

Assert.Equal(42, memoryStream.Position);
Assert.Equal(resultIsSmaller, result);

if (resultIsSmaller)
Assert.True(after < before);
Assert.True(after < before, $"Expected {after} to be smaller than {before}.");
else
Assert.Equal(before, after);

Expand All @@ -112,7 +113,7 @@ private long AssertCompress(string fileName, Func<string, bool> action, bool res
Assert.Equal(resultIsSmaller, result);

if (resultIsSmaller)
Assert.True(after < before);
Assert.True(after < before, $"Expected {after} to be smaller than {before}.");
else
Assert.Equal(before, after);

Expand Down

0 comments on commit fc6197f

Please sign in to comment.