Skip to content

Commit

Permalink
Refactor checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Mar 27, 2023
1 parent 4308af5 commit 364b546
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ public void ShouldThrowExceptionWhenSettingsIsNull()
[Fact]
public void ShouldApplyTheOperatorToTheImages()
{
if (Runtime.IsLinux && Runtime.IsArm64)
{
if (TestRuntime.HasFlakyLinuxArm64Result)
return;
}

using (var images = new MagickImageCollection())
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Magick.NET.Tests/MagickImageTests/TheToBase64Method.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ public void ShouldReturnBase64EncodedStringUsingTheSpecifiedFormat()
{
var base64 = image.ToBase64(MagickFormat.Jpeg);
Assert.NotNull(base64);
if (Runtime.IsLinux && Runtime.IsArm64)
if (TestRuntime.HasFlakyLinuxArm64Result)
Assert.InRange(base64.Length, 1140, 1144);
else
Assert.Equal(1140, base64.Length);

var bytes = Convert.FromBase64String(base64);
Assert.NotNull(bytes);
if (Runtime.IsLinux && Runtime.IsArm64)
if (TestRuntime.HasFlakyLinuxArm64Result)
Assert.InRange(bytes.Length, 853, 858);
else
Assert.Equal(853, bytes.Length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void ShouldReturnImageWithTheSameFormat()
var data = image.ToByteArray();

Assert.NotNull(data);
if (Runtime.IsLinux && Runtime.IsArm64)
if (TestRuntime.HasFlakyLinuxArm64Result)
Assert.InRange(data.Length, 18830, 18831);
else
Assert.Equal(18830, data.Length);
Expand All @@ -56,7 +56,7 @@ public void ShouldUseTheFormatOfTheDefines()
var data = image.ToByteArray(defines);

Assert.NotNull(data);
if (Runtime.IsLinux && Runtime.IsArm64)
if (TestRuntime.HasFlakyLinuxArm64Result)
Assert.InRange(data.Length, 853, 858);
else
Assert.Equal(853, data.Length);
Expand All @@ -75,7 +75,7 @@ public void ShouldUseTheSpecifiedFormat()
var data = image.ToByteArray(MagickFormat.Jpeg);

Assert.NotNull(data);
if (Runtime.IsLinux && Runtime.IsArm64)
if (TestRuntime.HasFlakyLinuxArm64Result)
Assert.InRange(data.Length, 60301, 60304);
else
Assert.Equal(60304, data.Length);
Expand Down
13 changes: 13 additions & 0 deletions tests/Magick.NET.Tests/TestHelpers/TestRuntime.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET.
// Licensed under the Apache License, Version 2.0.

using ImageMagick;

namespace Magick.NET.Tests
{
internal static class TestRuntime
{
public static bool HasFlakyLinuxArm64Result
=> Runtime.IsLinux && Runtime.IsArm64;
}
}

0 comments on commit 364b546

Please sign in to comment.