Skip to content

Commit a79d290

Browse files
committed
Improved isolated unit test.
1 parent ae8351a commit a79d290

File tree

1 file changed

+37
-28
lines changed

1 file changed

+37
-28
lines changed

tests/Magick.NET.Tests/Coders/TheEpsCoder.cs

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,61 +14,70 @@ public void ShouldReadTwoImages()
1414
{
1515
Assert.SkipUnless(Ghostscript.IsAvailable, "Ghostscript is not available");
1616

17-
using var images = new MagickImageCollection(Files.Coders.SwedenHeartEPS);
17+
IsolatedUnitTest.Execute(() =>
18+
{
19+
using var images = new MagickImageCollection(Files.Coders.SwedenHeartEPS);
1820

19-
Assert.Equal(2, images.Count);
21+
Assert.Equal(2, images.Count);
2022

21-
Assert.Equal(447U, images[0].Width);
22-
Assert.Equal(420U, images[0].Height);
23-
Assert.Equal(MagickFormat.Ept, images[0].Format);
23+
Assert.Equal(447U, images[0].Width);
24+
Assert.Equal(420U, images[0].Height);
25+
Assert.Equal(MagickFormat.Ept, images[0].Format);
2426

25-
Assert.Equal(447U, images[1].Width);
26-
Assert.Equal(420U, images[1].Height);
27-
Assert.Equal(MagickFormat.Tiff, images[1].Format);
27+
Assert.Equal(447U, images[1].Width);
28+
Assert.Equal(420U, images[1].Height);
29+
Assert.Equal(MagickFormat.Tiff, images[1].Format);
30+
});
2831
}
2932

3033
[Fact]
3134
public void ShouldReadMonoChromeImageWhenUseMonochromeIsTrue()
3235
{
3336
Assert.SkipUnless(Ghostscript.IsAvailable, "Ghostscript is not available");
3437

35-
var settings = new MagickReadSettings
38+
IsolatedUnitTest.Execute(() =>
3639
{
37-
UseMonochrome = true,
38-
};
39-
40-
using var image = new MagickImage(Files.Coders.SwedenHeartEPS, settings);
41-
42-
Assert.Equal(447U, image.Width);
43-
Assert.Equal(420U, image.Height);
44-
ColorAssert.Equal(MagickColors.Black, image, 223, 61);
45-
ColorAssert.Equal(MagickColors.Black, image, 263, 255);
46-
ColorAssert.Equal(MagickColors.White, image, 223, 62);
47-
ColorAssert.Equal(MagickColors.White, image, 193, 254);
40+
var settings = new MagickReadSettings
41+
{
42+
UseMonochrome = true,
43+
};
44+
45+
using var image = new MagickImage(Files.Coders.SwedenHeartEPS, settings);
46+
47+
Assert.Equal(447U, image.Width);
48+
Assert.Equal(420U, image.Height);
49+
ColorAssert.Equal(MagickColors.Black, image, 223, 61);
50+
ColorAssert.Equal(MagickColors.Black, image, 263, 255);
51+
ColorAssert.Equal(MagickColors.White, image, 223, 62);
52+
ColorAssert.Equal(MagickColors.White, image, 193, 254);
53+
});
4854
}
4955

5056
[Fact]
5157
public void ShouldReadClipPathsInTiffPreview()
5258
{
5359
Assert.SkipUnless(Ghostscript.IsAvailable, "Ghostscript is not available");
5460

55-
using var images = new MagickImageCollection(Files.Coders.SwedenHeartEPS);
61+
IsolatedUnitTest.Execute(() =>
62+
{
63+
using var images = new MagickImageCollection(Files.Coders.SwedenHeartEPS);
5664

57-
var profile = images[1].Get8BimProfile();
65+
var profile = images[1].Get8BimProfile();
5866

59-
Assert.NotNull(profile);
67+
Assert.NotNull(profile);
6068

61-
var clipPaths = profile.ClipPaths;
69+
var clipPaths = profile.ClipPaths;
6270

63-
Assert.Single(clipPaths);
71+
Assert.Single(clipPaths);
6472

65-
var clipPath = clipPaths[0].Path.CreateNavigator()?.OuterXml;
73+
var clipPath = clipPaths[0].Path.CreateNavigator()?.OuterXml;
6674

67-
var expected = @"<svg width=""447"" height=""420"">
75+
var expected = @"<svg width=""447"" height=""420"">
6876
<g>
6977
<path fill=""#00000000"" stroke=""#00000000"" stroke-width=""0"" stroke-antialiasing=""false"" d=""M 130 24&#xA;C 177.197 22.997 198.698 39.3 224 59&#xA;C 226.333 56.667 228.667 54.333 231 52&#xA;C 252.311 41.657 267.075 28.759 297 24&#xA;C 376.672 11.329 446.714 100.194 419 180&#xA;C 405.782 218.063 373.582 241.858 348 268&#xA;C 306.671 310.996 265.329 354.004 224 397&#xA;C 223 396.333 222 395.667 221 395&#xA;C 208.335 382.001 195.665 368.999 183 356&#xA;C 156.003 327.336 128.997 298.664 102 270&#xA;C 81.254 247.261 53.218 227.821 38 200&#xA;C 12.841 154.003 26.357 90.226 56 60&#xA;C 80.776 34.737 95.296 37.972 130 24 Z&#xA;"" />
7078
</g>
7179
</svg>";
72-
Assert.Equal(expected, clipPath);
80+
Assert.Equal(expected, clipPath);
81+
});
7382
}
7483
}

0 commit comments

Comments
 (0)