Browse Source

Migrate to xUnitV3

pull/3175/head
Stefan Nikolei 2 weeks ago
parent
commit
8930d4fd6f
  1. 2
      shared-infrastructure
  2. 1
      tests/Directory.Build.targets
  3. 8
      tests/ImageSharp.Tests.ProfilingSandbox/Program.cs
  4. 1
      tests/ImageSharp.Tests/ColorProfiles/Icc/ColorProfileConverterTests.Icc.cs
  5. 2
      tests/ImageSharp.Tests/Common/NumericsTests.cs
  6. 1
      tests/ImageSharp.Tests/Common/SimdUtilsTests.cs
  7. 1
      tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs
  8. 1
      tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs
  9. 1
      tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs
  10. 1
      tests/ImageSharp.Tests/Formats/Jpg/HuffmanScanEncoderTests.cs
  11. 1
      tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs
  12. 1
      tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs
  13. 1
      tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.AccurateDCT.cs
  14. 1
      tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs
  15. 1
      tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.StandardIntegerDCT.cs
  16. 2
      tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.cs
  17. 1
      tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs
  18. 1
      tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs
  19. 1
      tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs
  20. 2
      tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs
  21. 1
      tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs
  22. 1
      tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs
  23. 8
      tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs
  24. 1
      tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs
  25. 1
      tests/ImageSharp.Tests/Image/ImageTests.Decode_Cancellation.cs
  26. 1
      tests/ImageSharp.Tests/ImageSharp.Tests.csproj
  27. 2
      tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.cs
  28. 502
      tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs
  29. 6
      tests/ImageSharp.Tests/PixelFormats/L8Tests.cs
  30. 6
      tests/ImageSharp.Tests/PixelFormats/La16Tests.cs
  31. 3
      tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/PixelOperationsTests.Specialized.Generated.cs
  32. 1
      tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/_Common.ttinclude
  33. 82
      tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs
  34. 2
      tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs
  35. 4
      tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs
  36. 118
      tests/ImageSharp.Tests/Processing/Processors/Quantization/QuantizerTests.cs
  37. 1
      tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs
  38. 1
      tests/ImageSharp.Tests/Processing/Processors/Transforms/ProjectiveTransformTests.cs
  39. 1
      tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs
  40. 12
      tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs
  41. 1
      tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs
  42. 1
      tests/ImageSharp.Tests/ProfilingBenchmarks/ResizeProfilingBenchmarks.cs
  43. 2
      tests/ImageSharp.Tests/Quantization/AlphaAssociationQuantizerTests.cs
  44. 33
      tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs
  45. 30
      tests/ImageSharp.Tests/TestUtilities/BasicSerializer.cs
  46. 2
      tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs
  47. 2
      tests/ImageSharp.Tests/TestUtilities/ImageProviders/BasicTestPatternProvider.cs
  48. 3
      tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs
  49. 3
      tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs
  50. 2
      tests/ImageSharp.Tests/TestUtilities/ImageProviders/MemberMethodProvider.cs
  51. 2
      tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs
  52. 3
      tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs
  53. 2
      tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs
  54. 1
      tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs
  55. 15
      tests/ImageSharp.Tests/TestUtilities/SixLaborsXunitTestFramework.cs
  56. 2
      tests/ImageSharp.Tests/TestUtilities/TestPixel.cs
  57. 2
      tests/ImageSharp.Tests/TestUtilities/TestType.cs
  58. 2
      tests/ImageSharp.Tests/TestUtilities/TestVector4.cs
  59. 24
      tests/ImageSharp.Tests/TestUtilities/Tests/BasicSerializerTests.cs
  60. 2
      tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs
  61. 1
      tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs
  62. 1
      tests/ImageSharp.Tests/TestUtilities/Tests/MagickReferenceCodecTests.cs
  63. 1
      tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs
  64. 1
      tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs
  65. 1
      tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs
  66. 23
      tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs
  67. 1
      tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs
  68. 12
      tests/ImageSharp.Tests/TestUtilities/XUnit/ConditionalDiscovererException.cs
  69. 35
      tests/ImageSharp.Tests/TestUtilities/XUnit/ConditionalFact.cs
  70. 154
      tests/ImageSharp.Tests/TestUtilities/XUnit/ConditionalTestDiscoverer.cs
  71. 33
      tests/ImageSharp.Tests/TestUtilities/XUnit/ConditionalTheory.cs
  72. 15
      tests/ImageSharp.Tests/TestUtilities/XUnit/StaticReflectionConstants.cs
  73. 6
      tests/ImageSharp.Tests/ValidateDisposedMemoryAllocationsAttribute.cs

2
shared-infrastructure

@ -1 +1 @@
Subproject commit 20f15a2d47bba9d8375b5fd34fac283336ec9a5e Subproject commit 131fe3e59db92847b3d2bc8937bd35804dbcc8d5

1
tests/Directory.Build.targets

@ -25,7 +25,6 @@
--> -->
<PackageReference Update="Magick.NET-Q16-AnyCPU" Version="14.14.0" /> <PackageReference Update="Magick.NET-Q16-AnyCPU" Version="14.14.0" />
<PackageReference Update="Microsoft.DotNet.RemoteExecutor" Version="10.0.0-beta.25563.105" /> <PackageReference Update="Microsoft.DotNet.RemoteExecutor" Version="10.0.0-beta.25563.105" />
<PackageReference Update="Microsoft.DotNet.XUnitExtensions" Version="8.0.0-beta.23580.1" />
<PackageReference Update="Moq" Version="4.20.72" /> <PackageReference Update="Moq" Version="4.20.72" />
<PackageReference Update="NetVips" Version="3.0.0" /> <PackageReference Update="NetVips" Version="3.0.0" />
<PackageReference Update="NetVips.Native" Version="8.16.0" /> <PackageReference Update="NetVips.Native" Version="8.16.0" />

8
tests/ImageSharp.Tests.ProfilingSandbox/Program.cs

@ -4,7 +4,7 @@
using SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations; using SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations;
using SixLabors.ImageSharp.Tests.ProfilingBenchmarks; using SixLabors.ImageSharp.Tests.ProfilingBenchmarks;
using SixLabors.ImageSharp.Tests.ProfilingSandbox; using SixLabors.ImageSharp.Tests.ProfilingSandbox;
using Xunit.Abstractions; using Xunit;
// in this file, comments are used for disabling stuff for local execution // in this file, comments are used for disabling stuff for local execution
#pragma warning disable SA1515 #pragma warning disable SA1515
@ -32,7 +32,13 @@ static void RunToVector4ProfilingTest()
sealed class ConsoleOutput : ITestOutputHelper sealed class ConsoleOutput : ITestOutputHelper
{ {
public void Write(string message) => Console.Write(message);
public void Write(string format, params object[] args) => Console.Write(format, args);
public void WriteLine(string message) => Console.WriteLine(message); public void WriteLine(string message) => Console.WriteLine(message);
public void WriteLine(string format, params object[] args) => Console.WriteLine(format, args); public void WriteLine(string format, params object[] args) => Console.WriteLine(format, args);
public string Output { get; }
} }

1
tests/ImageSharp.Tests/ColorProfiles/Icc/ColorProfileConverterTests.Icc.cs

@ -6,7 +6,6 @@ using SixLabors.ImageSharp.ColorProfiles;
using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Icc;
using Wacton.Unicolour; using Wacton.Unicolour;
using Wacton.Unicolour.Icc; using Wacton.Unicolour.Icc;
using Xunit.Abstractions;
using Rgb = SixLabors.ImageSharp.ColorProfiles.Rgb; using Rgb = SixLabors.ImageSharp.ColorProfiles.Rgb;
namespace SixLabors.ImageSharp.Tests.ColorProfiles.Icc; namespace SixLabors.ImageSharp.Tests.ColorProfiles.Icc;

2
tests/ImageSharp.Tests/Common/NumericsTests.cs

@ -1,8 +1,6 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Six Labors Split License. // Licensed under the Six Labors Split License.
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.Common; namespace SixLabors.ImageSharp.Tests.Common;
public class NumericsTests public class NumericsTests

1
tests/ImageSharp.Tests/Common/SimdUtilsTests.cs

@ -9,7 +9,6 @@ using System.Runtime.Intrinsics.X86;
using SixLabors.ImageSharp.Common.Helpers; using SixLabors.ImageSharp.Common.Helpers;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.TestUtilities; using SixLabors.ImageSharp.Tests.TestUtilities;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.Common; namespace SixLabors.ImageSharp.Tests.Common;

1
tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs

@ -7,7 +7,6 @@ using System.Runtime.Intrinsics;
using SixLabors.ImageSharp.Formats.Jpeg.Components; using SixLabors.ImageSharp.Formats.Jpeg.Components;
using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
using SixLabors.ImageSharp.Tests.TestUtilities; using SixLabors.ImageSharp.Tests.TestUtilities;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.Formats.Jpg; namespace SixLabors.ImageSharp.Tests.Formats.Jpg;

1
tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs

@ -4,7 +4,6 @@
using SixLabors.ImageSharp.Formats.Jpeg.Components; using SixLabors.ImageSharp.Formats.Jpeg.Components;
using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
using SixLabors.ImageSharp.Tests.TestUtilities; using SixLabors.ImageSharp.Tests.TestUtilities;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.Formats.Jpg; namespace SixLabors.ImageSharp.Tests.Formats.Jpg;

1
tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs

@ -4,7 +4,6 @@
using SixLabors.ImageSharp.Formats.Jpeg.Components; using SixLabors.ImageSharp.Formats.Jpeg.Components;
using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
using SixLabors.ImageSharp.Tests.TestUtilities; using SixLabors.ImageSharp.Tests.TestUtilities;
using Xunit.Abstractions;
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Formats.Jpg; namespace SixLabors.ImageSharp.Tests.Formats.Jpg;

1
tests/ImageSharp.Tests/Formats/Jpg/HuffmanScanEncoderTests.cs

@ -2,7 +2,6 @@
// Licensed under the Six Labors Split License. // Licensed under the Six Labors Split License.
using SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder; using SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder;
using Xunit.Abstractions;
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Formats.Jpg; namespace SixLabors.ImageSharp.Tests.Formats.Jpg;

1
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs

@ -9,7 +9,6 @@ using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs; using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs;
using Xunit.Abstractions;
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Formats.Jpg; namespace SixLabors.ImageSharp.Tests.Formats.Jpg;

1
tests/ImageSharp.Tests/Formats/Jpg/ParseStreamTests.cs

@ -6,7 +6,6 @@ using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.Formats.Jpeg.Components; using SixLabors.ImageSharp.Formats.Jpeg.Components;
using SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder; using SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder;
using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.Formats.Jpg; namespace SixLabors.ImageSharp.Tests.Formats.Jpg;

1
tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.AccurateDCT.cs

@ -3,7 +3,6 @@
using SixLabors.ImageSharp.Formats.Jpeg.Components; using SixLabors.ImageSharp.Formats.Jpeg.Components;
using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.Formats.Jpg; namespace SixLabors.ImageSharp.Tests.Formats.Jpg;

1
tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.FastFloatingPointDCT.cs

@ -4,7 +4,6 @@
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
using SixLabors.ImageSharp.Formats.Jpeg.Components; using SixLabors.ImageSharp.Formats.Jpeg.Components;
using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.Formats.Jpg; namespace SixLabors.ImageSharp.Tests.Formats.Jpg;

1
tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.StandardIntegerDCT.cs

@ -3,7 +3,6 @@
using SixLabors.ImageSharp.Formats.Jpeg.Components; using SixLabors.ImageSharp.Formats.Jpeg.Components;
using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
using Xunit.Abstractions;
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Formats.Jpg; namespace SixLabors.ImageSharp.Tests.Formats.Jpg;

2
tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.cs

@ -1,8 +1,6 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Six Labors Split License. // Licensed under the Six Labors Split License.
using Xunit.Abstractions;
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Formats.Jpg; namespace SixLabors.ImageSharp.Tests.Formats.Jpg;

1
tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs

@ -9,7 +9,6 @@ using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Icc;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
using Xunit.Abstractions;
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Formats.Jpg; namespace SixLabors.ImageSharp.Tests.Formats.Jpg;

1
tests/ImageSharp.Tests/Formats/Jpg/SpectralToPixelConversionTests.cs

@ -7,7 +7,6 @@ using SixLabors.ImageSharp.IO;
using SixLabors.ImageSharp.Metadata; using SixLabors.ImageSharp.Metadata;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.Formats.Jpg; namespace SixLabors.ImageSharp.Tests.Formats.Jpg;

1
tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegFixture.cs

@ -6,7 +6,6 @@ using System.Text;
using SixLabors.ImageSharp.Formats.Jpeg; using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.Formats.Jpeg.Components; using SixLabors.ImageSharp.Formats.Jpeg.Components;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using Xunit.Abstractions;
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;

2
tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs

@ -5,8 +5,6 @@ using System.Numerics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.Formats.Jpeg.Components; using SixLabors.ImageSharp.Formats.Jpeg.Components;
using Xunit.Abstractions;
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;

1
tests/ImageSharp.Tests/Formats/Jpg/Utils/VerifyJpeg.cs

@ -3,7 +3,6 @@
using SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder; using SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;

1
tests/ImageSharp.Tests/Formats/Png/PngEncoderFilterTests.cs

@ -6,7 +6,6 @@
using SixLabors.ImageSharp.Formats.Png; using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.Formats.Png.Filters; using SixLabors.ImageSharp.Formats.Png.Filters;
using SixLabors.ImageSharp.Tests.TestUtilities; using SixLabors.ImageSharp.Tests.TestUtilities;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.Formats.Png; namespace SixLabors.ImageSharp.Tests.Formats.Png;

8
tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs

@ -200,14 +200,14 @@ public partial class PngEncoderTests
return; return;
} }
foreach (object[] filterMethod in PngFilterMethods) foreach (TheoryDataRow<PngFilterMethod> filterMethod in PngFilterMethods)
{ {
foreach (PngInterlaceMode interlaceMode in InterlaceMode) foreach (PngInterlaceMode interlaceMode in InterlaceMode)
{ {
TestPngEncoderCore( TestPngEncoderCore(
provider, provider,
pngColorType, pngColorType,
(PngFilterMethod)filterMethod[0], filterMethod.Data,
pngBitDepth, pngBitDepth,
interlaceMode, interlaceMode,
appendPngColorType: true, appendPngColorType: true,
@ -236,14 +236,14 @@ public partial class PngEncoderTests
public void WorksWithAllBitDepthsAndExcludeAllFilter<TPixel>(TestImageProvider<TPixel> provider, PngColorType pngColorType, PngBitDepth pngBitDepth) public void WorksWithAllBitDepthsAndExcludeAllFilter<TPixel>(TestImageProvider<TPixel> provider, PngColorType pngColorType, PngBitDepth pngBitDepth)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
foreach (object[] filterMethod in PngFilterMethods) foreach (TheoryDataRow<PngFilterMethod> filterMethod in PngFilterMethods)
{ {
foreach (PngInterlaceMode interlaceMode in InterlaceMode) foreach (PngInterlaceMode interlaceMode in InterlaceMode)
{ {
TestPngEncoderCore( TestPngEncoderCore(
provider, provider,
pngColorType, pngColorType,
(PngFilterMethod)filterMethod[0], filterMethod.Data,
pngBitDepth, pngBitDepth,
interlaceMode, interlaceMode,
appendPngColorType: true, appendPngColorType: true,

1
tests/ImageSharp.Tests/Helpers/ParallelRowIteratorTests.cs

@ -7,7 +7,6 @@ using Castle.Core.Configuration;
using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.Helpers; namespace SixLabors.ImageSharp.Tests.Helpers;

1
tests/ImageSharp.Tests/Image/ImageTests.Decode_Cancellation.cs

@ -3,6 +3,7 @@
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Tests.TestUtilities; using SixLabors.ImageSharp.Tests.TestUtilities;
using XUnit;
namespace SixLabors.ImageSharp.Tests; namespace SixLabors.ImageSharp.Tests;

1
tests/ImageSharp.Tests/ImageSharp.Tests.csproj

@ -45,7 +45,6 @@
<PackageReference Include="BenchmarkDotNet" Version="0.13.0" /> <PackageReference Include="BenchmarkDotNet" Version="0.13.0" />
<PackageReference Include="Magick.NET-Q16-AnyCPU" /> <PackageReference Include="Magick.NET-Q16-AnyCPU" />
<PackageReference Include="Microsoft.DotNet.RemoteExecutor" /> <PackageReference Include="Microsoft.DotNet.RemoteExecutor" />
<PackageReference Include="Microsoft.DotNet.XUnitExtensions" />
<PackageReference Include="Moq" /> <PackageReference Include="Moq" />
<PackageReference Include="runtime.osx.10.10-x64.CoreCompat.System.Drawing" Condition="'$(IsOSX)'=='true'" /> <PackageReference Include="runtime.osx.10.10-x64.CoreCompat.System.Drawing" Condition="'$(IsOSX)'=='true'" />
<PackageReference Include="SharpZipLib" /> <PackageReference Include="SharpZipLib" />

2
tests/ImageSharp.Tests/Memory/Allocators/UniformUnmanagedMemoryPoolTests.cs

@ -5,7 +5,7 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Microsoft.DotNet.RemoteExecutor; using Microsoft.DotNet.RemoteExecutor;
using SixLabors.ImageSharp.Memory.Internals; using SixLabors.ImageSharp.Memory.Internals;
using Xunit.Abstractions; using XUnit;
namespace SixLabors.ImageSharp.Tests.Memory.Allocators; namespace SixLabors.ImageSharp.Tests.Memory.Allocators;

502
tests/ImageSharp.Tests/Metadata/Profiles/Exif/Values/ExifValuesTests.cs

@ -11,329 +11,329 @@ public class ExifValuesTests
{ {
public static TheoryData<ExifTag> ByteTags => new() public static TheoryData<ExifTag> ByteTags => new()
{ {
{ ExifTag.FaxProfile }, (ExifTag)ExifTag.FaxProfile,
{ ExifTag.ModeNumber }, (ExifTag)ExifTag.ModeNumber,
{ ExifTag.GPSAltitudeRef } (ExifTag)ExifTag.GPSAltitudeRef
}; };
public static TheoryData<ExifTag> ByteArrayTags => new() public static TheoryData<ExifTag> ByteArrayTags => new()
{ {
{ ExifTag.ClipPath }, (ExifTag)ExifTag.ClipPath,
{ ExifTag.VersionYear }, (ExifTag)ExifTag.VersionYear,
{ ExifTag.XMP }, (ExifTag)ExifTag.XMP,
{ ExifTag.CFAPattern2 }, (ExifTag)ExifTag.CFAPattern2,
{ ExifTag.TIFFEPStandardID }, (ExifTag)ExifTag.TIFFEPStandardID,
{ ExifTag.GPSVersionID }, (ExifTag)ExifTag.GPSVersionID,
}; };
public static TheoryData<ExifTag> DoubleArrayTags => new() public static TheoryData<ExifTag> DoubleArrayTags => new()
{ {
{ ExifTag.PixelScale }, (ExifTag)ExifTag.PixelScale,
{ ExifTag.IntergraphMatrix }, (ExifTag)ExifTag.IntergraphMatrix,
{ ExifTag.ModelTiePoint }, (ExifTag)ExifTag.ModelTiePoint,
{ ExifTag.ModelTransform } (ExifTag)ExifTag.ModelTransform
}; };
public static TheoryData<ExifTag> LongTags => new() public static TheoryData<ExifTag> LongTags => new()
{ {
{ ExifTag.SubfileType }, (ExifTag)ExifTag.SubfileType,
{ ExifTag.SubIFDOffset }, (ExifTag)ExifTag.SubIFDOffset,
{ ExifTag.GPSIFDOffset }, (ExifTag)ExifTag.GPSIFDOffset,
{ ExifTag.T4Options }, (ExifTag)ExifTag.T4Options,
{ ExifTag.T6Options }, (ExifTag)ExifTag.T6Options,
{ ExifTag.XClipPathUnits }, (ExifTag)ExifTag.XClipPathUnits,
{ ExifTag.YClipPathUnits }, (ExifTag)ExifTag.YClipPathUnits,
{ ExifTag.ProfileType }, (ExifTag)ExifTag.ProfileType,
{ ExifTag.CodingMethods }, (ExifTag)ExifTag.CodingMethods,
{ ExifTag.T82ptions }, (ExifTag)ExifTag.T82ptions,
{ ExifTag.JPEGInterchangeFormat }, (ExifTag)ExifTag.JPEGInterchangeFormat,
{ ExifTag.JPEGInterchangeFormatLength }, (ExifTag)ExifTag.JPEGInterchangeFormatLength,
{ ExifTag.MDFileTag }, (ExifTag)ExifTag.MDFileTag,
{ ExifTag.StandardOutputSensitivity }, (ExifTag)ExifTag.StandardOutputSensitivity,
{ ExifTag.RecommendedExposureIndex }, (ExifTag)ExifTag.RecommendedExposureIndex,
{ ExifTag.ISOSpeed }, (ExifTag)ExifTag.ISOSpeed,
{ ExifTag.ISOSpeedLatitudeyyy }, (ExifTag)ExifTag.ISOSpeedLatitudeyyy,
{ ExifTag.ISOSpeedLatitudezzz }, (ExifTag)ExifTag.ISOSpeedLatitudezzz,
{ ExifTag.FaxRecvParams }, (ExifTag)ExifTag.FaxRecvParams,
{ ExifTag.FaxRecvTime }, (ExifTag)ExifTag.FaxRecvTime,
{ ExifTag.ImageNumber }, (ExifTag)ExifTag.ImageNumber,
}; };
public static TheoryData<ExifTag> LongArrayTags => new() public static TheoryData<ExifTag> LongArrayTags => new()
{ {
{ ExifTag.FreeOffsets }, (ExifTag)ExifTag.FreeOffsets,
{ ExifTag.FreeByteCounts }, (ExifTag)ExifTag.FreeByteCounts,
{ ExifTag.ColorResponseUnit }, (ExifTag)ExifTag.ColorResponseUnit,
{ ExifTag.SMinSampleValue }, (ExifTag)ExifTag.SMinSampleValue,
{ ExifTag.SMaxSampleValue }, (ExifTag)ExifTag.SMaxSampleValue,
{ ExifTag.JPEGQTables }, (ExifTag)ExifTag.JPEGQTables,
{ ExifTag.JPEGDCTables }, (ExifTag)ExifTag.JPEGDCTables,
{ ExifTag.JPEGACTables }, (ExifTag)ExifTag.JPEGACTables,
{ ExifTag.StripRowCounts }, (ExifTag)ExifTag.StripRowCounts,
{ ExifTag.IntergraphRegisters } (ExifTag)ExifTag.IntergraphRegisters
}; };
public static TheoryData<ExifTag> NumberTags => new() public static TheoryData<ExifTag> NumberTags => new()
{ {
{ ExifTag.ImageWidth }, (ExifTag)ExifTag.ImageWidth,
{ ExifTag.ImageLength }, (ExifTag)ExifTag.ImageLength,
{ ExifTag.TileWidth }, (ExifTag)ExifTag.TileWidth,
{ ExifTag.TileLength }, (ExifTag)ExifTag.TileLength,
{ ExifTag.BadFaxLines }, (ExifTag)ExifTag.BadFaxLines,
{ ExifTag.ConsecutiveBadFaxLines }, (ExifTag)ExifTag.ConsecutiveBadFaxLines,
{ ExifTag.PixelXDimension }, (ExifTag)ExifTag.PixelXDimension,
{ ExifTag.PixelYDimension } (ExifTag)ExifTag.PixelYDimension
}; };
public static TheoryData<ExifTag> NumberArrayTags => new() public static TheoryData<ExifTag> NumberArrayTags => new()
{ {
{ ExifTag.StripOffsets }, (ExifTag)ExifTag.StripOffsets,
{ ExifTag.StripByteCounts }, (ExifTag)ExifTag.StripByteCounts,
{ ExifTag.TileByteCounts }, (ExifTag)ExifTag.TileByteCounts,
{ ExifTag.TileOffsets }, (ExifTag)ExifTag.TileOffsets,
{ ExifTag.ImageLayer } (ExifTag)ExifTag.ImageLayer
}; };
public static TheoryData<ExifTag> RationalTags => new() public static TheoryData<ExifTag> RationalTags => new()
{ {
{ ExifTag.XPosition }, (ExifTag)ExifTag.XPosition,
{ ExifTag.YPosition }, (ExifTag)ExifTag.YPosition,
{ ExifTag.XResolution }, (ExifTag)ExifTag.XResolution,
{ ExifTag.YResolution }, (ExifTag)ExifTag.YResolution,
{ ExifTag.BatteryLevel }, (ExifTag)ExifTag.BatteryLevel,
{ ExifTag.ExposureTime }, (ExifTag)ExifTag.ExposureTime,
{ ExifTag.FNumber }, (ExifTag)ExifTag.FNumber,
{ ExifTag.MDScalePixel }, (ExifTag)ExifTag.MDScalePixel,
{ ExifTag.CompressedBitsPerPixel }, (ExifTag)ExifTag.CompressedBitsPerPixel,
{ ExifTag.ApertureValue }, (ExifTag)ExifTag.ApertureValue,
{ ExifTag.MaxApertureValue }, (ExifTag)ExifTag.MaxApertureValue,
{ ExifTag.SubjectDistance }, (ExifTag)ExifTag.SubjectDistance,
{ ExifTag.FocalLength }, (ExifTag)ExifTag.FocalLength,
{ ExifTag.FlashEnergy2 }, (ExifTag)ExifTag.FlashEnergy2,
{ ExifTag.FocalPlaneXResolution2 }, (ExifTag)ExifTag.FocalPlaneXResolution2,
{ ExifTag.FocalPlaneYResolution2 }, (ExifTag)ExifTag.FocalPlaneYResolution2,
{ ExifTag.ExposureIndex2 }, (ExifTag)ExifTag.ExposureIndex2,
{ ExifTag.Humidity }, (ExifTag)ExifTag.Humidity,
{ ExifTag.Pressure }, (ExifTag)ExifTag.Pressure,
{ ExifTag.Acceleration }, (ExifTag)ExifTag.Acceleration,
{ ExifTag.FlashEnergy }, (ExifTag)ExifTag.FlashEnergy,
{ ExifTag.FocalPlaneXResolution }, (ExifTag)ExifTag.FocalPlaneXResolution,
{ ExifTag.FocalPlaneYResolution }, (ExifTag)ExifTag.FocalPlaneYResolution,
{ ExifTag.ExposureIndex }, (ExifTag)ExifTag.ExposureIndex,
{ ExifTag.DigitalZoomRatio }, (ExifTag)ExifTag.DigitalZoomRatio,
{ ExifTag.GPSAltitude }, (ExifTag)ExifTag.GPSAltitude,
{ ExifTag.GPSDOP }, (ExifTag)ExifTag.GPSDOP,
{ ExifTag.GPSSpeed }, (ExifTag)ExifTag.GPSSpeed,
{ ExifTag.GPSTrack }, (ExifTag)ExifTag.GPSTrack,
{ ExifTag.GPSImgDirection }, (ExifTag)ExifTag.GPSImgDirection,
{ ExifTag.GPSDestBearing }, (ExifTag)ExifTag.GPSDestBearing,
{ ExifTag.GPSDestDistance }, (ExifTag)ExifTag.GPSDestDistance,
{ ExifTag.GPSHPositioningError }, (ExifTag)ExifTag.GPSHPositioningError,
}; };
public static TheoryData<ExifTag> RationalArrayTags => new() public static TheoryData<ExifTag> RationalArrayTags => new()
{ {
{ ExifTag.WhitePoint }, (ExifTag)ExifTag.WhitePoint,
{ ExifTag.PrimaryChromaticities }, (ExifTag)ExifTag.PrimaryChromaticities,
{ ExifTag.YCbCrCoefficients }, (ExifTag)ExifTag.YCbCrCoefficients,
{ ExifTag.ReferenceBlackWhite }, (ExifTag)ExifTag.ReferenceBlackWhite,
{ ExifTag.GPSLatitude }, (ExifTag)ExifTag.GPSLatitude,
{ ExifTag.GPSLongitude }, (ExifTag)ExifTag.GPSLongitude,
{ ExifTag.GPSTimestamp }, (ExifTag)ExifTag.GPSTimestamp,
{ ExifTag.GPSDestLatitude }, (ExifTag)ExifTag.GPSDestLatitude,
{ ExifTag.GPSDestLongitude }, (ExifTag)ExifTag.GPSDestLongitude,
{ ExifTag.LensSpecification } (ExifTag)ExifTag.LensSpecification
}; };
public static TheoryData<ExifTag> ShortTags => new() public static TheoryData<ExifTag> ShortTags => new()
{ {
{ ExifTag.OldSubfileType }, (ExifTag)ExifTag.OldSubfileType,
{ ExifTag.Compression }, (ExifTag)ExifTag.Compression,
{ ExifTag.PhotometricInterpretation }, (ExifTag)ExifTag.PhotometricInterpretation,
{ ExifTag.Thresholding }, (ExifTag)ExifTag.Thresholding,
{ ExifTag.CellWidth }, (ExifTag)ExifTag.CellWidth,
{ ExifTag.CellLength }, (ExifTag)ExifTag.CellLength,
{ ExifTag.FillOrder }, (ExifTag)ExifTag.FillOrder,
{ ExifTag.Orientation }, (ExifTag)ExifTag.Orientation,
{ ExifTag.SamplesPerPixel }, (ExifTag)ExifTag.SamplesPerPixel,
{ ExifTag.PlanarConfiguration }, (ExifTag)ExifTag.PlanarConfiguration,
{ ExifTag.Predictor }, (ExifTag)ExifTag.Predictor,
{ ExifTag.GrayResponseUnit }, (ExifTag)ExifTag.GrayResponseUnit,
{ ExifTag.ResolutionUnit }, (ExifTag)ExifTag.ResolutionUnit,
{ ExifTag.CleanFaxData }, (ExifTag)ExifTag.CleanFaxData,
{ ExifTag.InkSet }, (ExifTag)ExifTag.InkSet,
{ ExifTag.NumberOfInks }, (ExifTag)ExifTag.NumberOfInks,
{ ExifTag.DotRange }, (ExifTag)ExifTag.DotRange,
{ ExifTag.Indexed }, (ExifTag)ExifTag.Indexed,
{ ExifTag.OPIProxy }, (ExifTag)ExifTag.OPIProxy,
{ ExifTag.JPEGProc }, (ExifTag)ExifTag.JPEGProc,
{ ExifTag.JPEGRestartInterval }, (ExifTag)ExifTag.JPEGRestartInterval,
{ ExifTag.YCbCrPositioning }, (ExifTag)ExifTag.YCbCrPositioning,
{ ExifTag.Rating }, (ExifTag)ExifTag.Rating,
{ ExifTag.RatingPercent }, (ExifTag)ExifTag.RatingPercent,
{ ExifTag.ExposureProgram }, (ExifTag)ExifTag.ExposureProgram,
{ ExifTag.Interlace }, (ExifTag)ExifTag.Interlace,
{ ExifTag.SelfTimerMode }, (ExifTag)ExifTag.SelfTimerMode,
{ ExifTag.SensitivityType }, (ExifTag)ExifTag.SensitivityType,
{ ExifTag.MeteringMode }, (ExifTag)ExifTag.MeteringMode,
{ ExifTag.LightSource }, (ExifTag)ExifTag.LightSource,
{ ExifTag.FocalPlaneResolutionUnit2 }, (ExifTag)ExifTag.FocalPlaneResolutionUnit2,
{ ExifTag.SensingMethod2 }, (ExifTag)ExifTag.SensingMethod2,
{ ExifTag.Flash }, (ExifTag)ExifTag.Flash,
{ ExifTag.ColorSpace }, (ExifTag)ExifTag.ColorSpace,
{ ExifTag.FocalPlaneResolutionUnit }, (ExifTag)ExifTag.FocalPlaneResolutionUnit,
{ ExifTag.SensingMethod }, (ExifTag)ExifTag.SensingMethod,
{ ExifTag.CustomRendered }, (ExifTag)ExifTag.CustomRendered,
{ ExifTag.ExposureMode }, (ExifTag)ExifTag.ExposureMode,
{ ExifTag.WhiteBalance }, (ExifTag)ExifTag.WhiteBalance,
{ ExifTag.FocalLengthIn35mmFilm }, (ExifTag)ExifTag.FocalLengthIn35mmFilm,
{ ExifTag.SceneCaptureType }, (ExifTag)ExifTag.SceneCaptureType,
{ ExifTag.GainControl }, (ExifTag)ExifTag.GainControl,
{ ExifTag.Contrast }, (ExifTag)ExifTag.Contrast,
{ ExifTag.Saturation }, (ExifTag)ExifTag.Saturation,
{ ExifTag.Sharpness }, (ExifTag)ExifTag.Sharpness,
{ ExifTag.SubjectDistanceRange }, (ExifTag)ExifTag.SubjectDistanceRange,
{ ExifTag.GPSDifferential } (ExifTag)ExifTag.GPSDifferential
}; };
public static TheoryData<ExifTag> ShortArrayTags => new() public static TheoryData<ExifTag> ShortArrayTags => new()
{ {
{ ExifTag.BitsPerSample }, (ExifTag)ExifTag.BitsPerSample,
{ ExifTag.MinSampleValue }, (ExifTag)ExifTag.MinSampleValue,
{ ExifTag.MaxSampleValue }, (ExifTag)ExifTag.MaxSampleValue,
{ ExifTag.GrayResponseCurve }, (ExifTag)ExifTag.GrayResponseCurve,
{ ExifTag.ColorMap }, (ExifTag)ExifTag.ColorMap,
{ ExifTag.ExtraSamples }, (ExifTag)ExifTag.ExtraSamples,
{ ExifTag.PageNumber }, (ExifTag)ExifTag.PageNumber,
{ ExifTag.TransferFunction }, (ExifTag)ExifTag.TransferFunction,
{ ExifTag.HalftoneHints }, (ExifTag)ExifTag.HalftoneHints,
{ ExifTag.SampleFormat }, (ExifTag)ExifTag.SampleFormat,
{ ExifTag.TransferRange }, (ExifTag)ExifTag.TransferRange,
{ ExifTag.DefaultImageColor }, (ExifTag)ExifTag.DefaultImageColor,
{ ExifTag.JPEGLosslessPredictors }, (ExifTag)ExifTag.JPEGLosslessPredictors,
{ ExifTag.JPEGPointTransforms }, (ExifTag)ExifTag.JPEGPointTransforms,
{ ExifTag.YCbCrSubsampling }, (ExifTag)ExifTag.YCbCrSubsampling,
{ ExifTag.CFARepeatPatternDim }, (ExifTag)ExifTag.CFARepeatPatternDim,
{ ExifTag.IntergraphPacketData }, (ExifTag)ExifTag.IntergraphPacketData,
{ ExifTag.ISOSpeedRatings }, (ExifTag)ExifTag.ISOSpeedRatings,
{ ExifTag.SubjectArea }, (ExifTag)ExifTag.SubjectArea,
{ ExifTag.SubjectLocation } (ExifTag)ExifTag.SubjectLocation
}; };
public static TheoryData<ExifTag> SignedRationalTags => new() public static TheoryData<ExifTag> SignedRationalTags => new()
{ {
{ ExifTag.ShutterSpeedValue }, (ExifTag)ExifTag.ShutterSpeedValue,
{ ExifTag.BrightnessValue }, (ExifTag)ExifTag.BrightnessValue,
{ ExifTag.ExposureBiasValue }, (ExifTag)ExifTag.ExposureBiasValue,
{ ExifTag.AmbientTemperature }, (ExifTag)ExifTag.AmbientTemperature,
{ ExifTag.WaterDepth }, (ExifTag)ExifTag.WaterDepth,
{ ExifTag.CameraElevationAngle } (ExifTag)ExifTag.CameraElevationAngle
}; };
public static TheoryData<ExifTag> SignedRationalArrayTags => new() public static TheoryData<ExifTag> SignedRationalArrayTags => new()
{ {
{ ExifTag.Decode } (ExifTag)ExifTag.Decode
}; };
public static TheoryData<ExifTag> SignedShortArrayTags => new() public static TheoryData<ExifTag> SignedShortArrayTags => new()
{ {
{ ExifTag.TimeZoneOffset } (ExifTag)ExifTag.TimeZoneOffset
}; };
public static TheoryData<ExifTag> StringTags => new() public static TheoryData<ExifTag> StringTags => new()
{ {
{ ExifTag.ImageDescription }, (ExifTag)ExifTag.ImageDescription,
{ ExifTag.Make }, (ExifTag)ExifTag.Make,
{ ExifTag.Model }, (ExifTag)ExifTag.Model,
{ ExifTag.Software }, (ExifTag)ExifTag.Software,
{ ExifTag.DateTime }, (ExifTag)ExifTag.DateTime,
{ ExifTag.Artist }, (ExifTag)ExifTag.Artist,
{ ExifTag.HostComputer }, (ExifTag)ExifTag.HostComputer,
{ ExifTag.Copyright }, (ExifTag)ExifTag.Copyright,
{ ExifTag.DocumentName }, (ExifTag)ExifTag.DocumentName,
{ ExifTag.PageName }, (ExifTag)ExifTag.PageName,
{ ExifTag.InkNames }, (ExifTag)ExifTag.InkNames,
{ ExifTag.TargetPrinter }, (ExifTag)ExifTag.TargetPrinter,
{ ExifTag.ImageID }, (ExifTag)ExifTag.ImageID,
{ ExifTag.MDLabName }, (ExifTag)ExifTag.MDLabName,
{ ExifTag.MDSampleInfo }, (ExifTag)ExifTag.MDSampleInfo,
{ ExifTag.MDPrepDate }, (ExifTag)ExifTag.MDPrepDate,
{ ExifTag.MDPrepTime }, (ExifTag)ExifTag.MDPrepTime,
{ ExifTag.MDFileUnits }, (ExifTag)ExifTag.MDFileUnits,
{ ExifTag.SEMInfo }, (ExifTag)ExifTag.SEMInfo,
{ ExifTag.SpectralSensitivity }, (ExifTag)ExifTag.SpectralSensitivity,
{ ExifTag.DateTimeOriginal }, (ExifTag)ExifTag.DateTimeOriginal,
{ ExifTag.DateTimeDigitized }, (ExifTag)ExifTag.DateTimeDigitized,
{ ExifTag.SubsecTime }, (ExifTag)ExifTag.SubsecTime,
{ ExifTag.SubsecTimeOriginal }, (ExifTag)ExifTag.SubsecTimeOriginal,
{ ExifTag.SubsecTimeDigitized }, (ExifTag)ExifTag.SubsecTimeDigitized,
{ ExifTag.RelatedSoundFile }, (ExifTag)ExifTag.RelatedSoundFile,
{ ExifTag.FaxSubaddress }, (ExifTag)ExifTag.FaxSubaddress,
{ ExifTag.OffsetTime }, (ExifTag)ExifTag.OffsetTime,
{ ExifTag.OffsetTimeOriginal }, (ExifTag)ExifTag.OffsetTimeOriginal,
{ ExifTag.OffsetTimeDigitized }, (ExifTag)ExifTag.OffsetTimeDigitized,
{ ExifTag.SecurityClassification }, (ExifTag)ExifTag.SecurityClassification,
{ ExifTag.ImageHistory }, (ExifTag)ExifTag.ImageHistory,
{ ExifTag.ImageUniqueID }, (ExifTag)ExifTag.ImageUniqueID,
{ ExifTag.OwnerName }, (ExifTag)ExifTag.OwnerName,
{ ExifTag.SerialNumber }, (ExifTag)ExifTag.SerialNumber,
{ ExifTag.LensMake }, (ExifTag)ExifTag.LensMake,
{ ExifTag.LensModel }, (ExifTag)ExifTag.LensModel,
{ ExifTag.LensSerialNumber }, (ExifTag)ExifTag.LensSerialNumber,
{ ExifTag.GDALMetadata }, (ExifTag)ExifTag.GDALMetadata,
{ ExifTag.GDALNoData }, (ExifTag)ExifTag.GDALNoData,
{ ExifTag.GPSLatitudeRef }, (ExifTag)ExifTag.GPSLatitudeRef,
{ ExifTag.GPSLongitudeRef }, (ExifTag)ExifTag.GPSLongitudeRef,
{ ExifTag.GPSSatellites }, (ExifTag)ExifTag.GPSSatellites,
{ ExifTag.GPSStatus }, (ExifTag)ExifTag.GPSStatus,
{ ExifTag.GPSMeasureMode }, (ExifTag)ExifTag.GPSMeasureMode,
{ ExifTag.GPSSpeedRef }, (ExifTag)ExifTag.GPSSpeedRef,
{ ExifTag.GPSTrackRef }, (ExifTag)ExifTag.GPSTrackRef,
{ ExifTag.GPSImgDirectionRef }, (ExifTag)ExifTag.GPSImgDirectionRef,
{ ExifTag.GPSMapDatum }, (ExifTag)ExifTag.GPSMapDatum,
{ ExifTag.GPSDestLatitudeRef }, (ExifTag)ExifTag.GPSDestLatitudeRef,
{ ExifTag.GPSDestLongitudeRef }, (ExifTag)ExifTag.GPSDestLongitudeRef,
{ ExifTag.GPSDestBearingRef }, (ExifTag)ExifTag.GPSDestBearingRef,
{ ExifTag.GPSDestDistanceRef }, (ExifTag)ExifTag.GPSDestDistanceRef,
{ ExifTag.GPSDateStamp }, (ExifTag)ExifTag.GPSDateStamp,
}; };
public static TheoryData<ExifTag> UndefinedTags => new() public static TheoryData<ExifTag> UndefinedTags => new()
{ {
{ ExifTag.FileSource }, (ExifTag)ExifTag.FileSource,
{ ExifTag.SceneType } (ExifTag)ExifTag.SceneType
}; };
public static TheoryData<ExifTag> UndefinedArrayTags => new() public static TheoryData<ExifTag> UndefinedArrayTags => new()
{ {
{ ExifTag.JPEGTables }, (ExifTag)ExifTag.JPEGTables,
{ ExifTag.OECF }, (ExifTag)ExifTag.OECF,
{ ExifTag.ExifVersion }, (ExifTag)ExifTag.ExifVersion,
{ ExifTag.ComponentsConfiguration }, (ExifTag)ExifTag.ComponentsConfiguration,
{ ExifTag.MakerNote }, (ExifTag)ExifTag.MakerNote,
{ ExifTag.FlashpixVersion }, (ExifTag)ExifTag.FlashpixVersion,
{ ExifTag.SpatialFrequencyResponse }, (ExifTag)ExifTag.SpatialFrequencyResponse,
{ ExifTag.SpatialFrequencyResponse2 }, (ExifTag)ExifTag.SpatialFrequencyResponse2,
{ ExifTag.Noise }, (ExifTag)ExifTag.Noise,
{ ExifTag.CFAPattern }, (ExifTag)ExifTag.CFAPattern,
{ ExifTag.DeviceSettingDescription }, (ExifTag)ExifTag.DeviceSettingDescription,
{ ExifTag.ImageSourceData }, (ExifTag)ExifTag.ImageSourceData,
}; };
public static TheoryData<ExifTag> EncodedStringTags => new() public static TheoryData<ExifTag> EncodedStringTags => new()
{ {
{ ExifTag.UserComment }, (ExifTag)ExifTag.UserComment,
{ ExifTag.GPSProcessingMethod }, (ExifTag)ExifTag.GPSProcessingMethod,
{ ExifTag.GPSAreaInformation } (ExifTag)ExifTag.GPSAreaInformation
}; };
public static TheoryData<ExifTag> Ucs2StringTags => new() public static TheoryData<ExifTag> Ucs2StringTags => new()
{ {
{ ExifTag.XPTitle }, (ExifTag)ExifTag.XPTitle,
{ ExifTag.XPComment }, (ExifTag)ExifTag.XPComment,
{ ExifTag.XPAuthor }, (ExifTag)ExifTag.XPAuthor,
{ ExifTag.XPKeywords }, (ExifTag)ExifTag.XPKeywords,
{ ExifTag.XPSubject }, (ExifTag)ExifTag.XPSubject,
}; };
[Theory] [Theory]

6
tests/ImageSharp.Tests/PixelFormats/L8Tests.cs

@ -12,7 +12,11 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats;
public class L8Tests public class L8Tests
{ {
public static readonly TheoryData<byte> LuminanceData public static readonly TheoryData<byte> LuminanceData
= new() { 0, 1, 2, 3, 5, 13, 31, 71, 73, 79, 83, 109, 127, 128, 131, 199, 250, 251, 254, 255 }; =
[
(byte)0, (byte)1, (byte)2, (byte)3, (byte)5, (byte)13, (byte)31, (byte)71, (byte)73, (byte)79, (byte)83,
(byte)109, (byte)127, (byte)128, (byte)131, (byte)199, (byte)250, (byte)251, (byte)254, (byte)255
];
[Theory] [Theory]
[InlineData(0)] [InlineData(0)]

6
tests/ImageSharp.Tests/PixelFormats/La16Tests.cs

@ -12,7 +12,11 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats;
public class La16Tests public class La16Tests
{ {
public static readonly TheoryData<byte> LuminanceData public static readonly TheoryData<byte> LuminanceData
= new() { 0, 1, 2, 3, 5, 13, 31, 71, 73, 79, 83, 109, 127, 128, 131, 199, 250, 251, 254, 255 }; =
[
(byte)0, (byte)1, (byte)2, (byte)3, (byte)5, (byte)13, (byte)31, (byte)71, (byte)73, (byte)79, (byte)83,
(byte)109, (byte)127, (byte)128, (byte)131, (byte)199, (byte)250, (byte)251, (byte)254, (byte)255
];
[Theory] [Theory]
[InlineData(0, 0)] [InlineData(0, 0)]

3
tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/PixelOperationsTests.Specialized.Generated.cs

@ -5,13 +5,12 @@
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using Xunit; using Xunit;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations; namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations;
public partial class PixelOperationsTests public partial class PixelOperationsTests
{ {
public partial class A8_OperationsTests : PixelOperationsTests<A8> public partial class A8_OperationsTests : PixelOperationsTests<A8>
{ {
public A8_OperationsTests(ITestOutputHelper output) public A8_OperationsTests(ITestOutputHelper output)

1
tests/ImageSharp.Tests/PixelFormats/PixelOperations/Generated/_Common.ttinclude

@ -10,7 +10,6 @@
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using Xunit; using Xunit;
using Xunit.Abstractions;
<#+ <#+
private static readonly string[] UnassociatedAlphaPixelTypes = private static readonly string[] UnassociatedAlphaPixelTypes =
[ [

82
tests/ImageSharp.Tests/PixelFormats/PixelOperations/PixelOperationsTests.cs

@ -10,7 +10,6 @@ using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.Common; using SixLabors.ImageSharp.Tests.Common;
using SixLabors.ImageSharp.Tests.TestUtilities; using SixLabors.ImageSharp.Tests.TestUtilities;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations; namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations;
@ -318,46 +317,47 @@ public abstract class PixelOperationsTests<TPixel> : MeasureFixture
(s, d) => this.Operations.ToVector4(this.Configuration, s, d.GetSpan())); (s, d) => this.Operations.ToVector4(this.Configuration, s, d.GetSpan()));
} }
public static readonly TheoryData<object> Generic_To_Data = new() public static readonly TheoryData<object> Generic_To_Data = new(
{ new object[]
new TestPixel<A8>(), {
new TestPixel<Abgr32>(), new TestPixel<A8>(),
new TestPixel<Abgr32P>(), new TestPixel<Abgr32>(),
new TestPixel<Argb32>(), new TestPixel<Abgr32P>(),
new TestPixel<Argb32P>(), new TestPixel<Argb32>(),
new TestPixel<Bgr24>(), new TestPixel<Argb32P>(),
new TestPixel<Bgr565>(), new TestPixel<Bgr24>(),
new TestPixel<Bgra32>(), new TestPixel<Bgr565>(),
new TestPixel<Bgra32P>(), new TestPixel<Bgra32>(),
new TestPixel<Bgra4444>(), new TestPixel<Bgra32P>(),
new TestPixel<Bgra5551>(), new TestPixel<Bgra4444>(),
new TestPixel<Byte4>(), new TestPixel<Bgra5551>(),
new TestPixel<HalfSingle>(), new TestPixel<Byte4>(),
new TestPixel<HalfVector2>(), new TestPixel<HalfSingle>(),
new TestPixel<HalfVector4>(), new TestPixel<HalfVector2>(),
new TestPixel<HalfVector4P>(), new TestPixel<HalfVector4>(),
new TestPixel<L16>(), new TestPixel<HalfVector4P>(),
new TestPixel<L8>(), new TestPixel<L16>(),
new TestPixel<La16>(), new TestPixel<L8>(),
new TestPixel<La32>(), new TestPixel<La16>(),
new TestPixel<NormalizedByte2>(), new TestPixel<La32>(),
new TestPixel<NormalizedByte4>(), new TestPixel<NormalizedByte2>(),
new TestPixel<NormalizedByte4P>(), new TestPixel<NormalizedByte4>(),
new TestPixel<NormalizedShort2>(), new TestPixel<NormalizedByte4P>(),
new TestPixel<NormalizedShort4>(), new TestPixel<NormalizedShort2>(),
new TestPixel<Rg32>(), new TestPixel<NormalizedShort4>(),
new TestPixel<Rgb24>(), new TestPixel<Rg32>(),
new TestPixel<Rgb48>(), new TestPixel<Rgb24>(),
new TestPixel<Rgba1010102>(), new TestPixel<Rgb48>(),
new TestPixel<Rgba32>(), new TestPixel<Rgba1010102>(),
new TestPixel<Rgba32P>(), new TestPixel<Rgba32>(),
new TestPixel<Rgba64>(), new TestPixel<Rgba32P>(),
new TestPixel<RgbaHalf>(), new TestPixel<Rgba64>(),
new TestPixel<RgbaHalfP>(), new TestPixel<RgbaHalf>(),
new TestPixel<RgbaVector>(), new TestPixel<RgbaHalfP>(),
new TestPixel<Short2>(), new TestPixel<RgbaVector>(),
new TestPixel<Short4>(), new TestPixel<Short2>(),
}; new TestPixel<Short4>(),
});
[Theory] [Theory]
[MemberData(nameof(Generic_To_Data))] [MemberData(nameof(Generic_To_Data))]

2
tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs

@ -8,7 +8,7 @@ using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors.Convolution; using SixLabors.ImageSharp.Processing.Processors.Convolution;
using SixLabors.ImageSharp.Tests.TestUtilities; using SixLabors.ImageSharp.Tests.TestUtilities;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using Xunit.Abstractions; using Xunit.Sdk;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution;

4
tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs

@ -43,8 +43,8 @@ public class DitherTests
public static readonly TheoryData<IDither> DefaultInstanceDitherers public static readonly TheoryData<IDither> DefaultInstanceDitherers
= new() = new()
{ {
default(ErrorDither), (IDither)default(ErrorDither),
default(OrderedDither) (IDither)default(OrderedDither)
}; };
private static readonly ImageComparer ValidatorComparer = ImageComparer.TolerantPercentage(0.05f); private static readonly ImageComparer ValidatorComparer = ImageComparer.TolerantPercentage(0.05f);

118
tests/ImageSharp.Tests/Processing/Processors/Quantization/QuantizerTests.cs

@ -78,75 +78,75 @@ public class QuantizerTests
KnownQuantizers.WebSafe, KnownQuantizers.WebSafe,
KnownQuantizers.Werner, KnownQuantizers.Werner,
KnownQuantizers.Wu, KnownQuantizers.Wu,
new HexadecatreeQuantizer(NoDitherOptions), (IQuantizer)new HexadecatreeQuantizer(NoDitherOptions),
new WebSafePaletteQuantizer(NoDitherOptions), (IQuantizer)new WebSafePaletteQuantizer(NoDitherOptions),
new WernerPaletteQuantizer(NoDitherOptions), (IQuantizer)new WernerPaletteQuantizer(NoDitherOptions),
new WuQuantizer(NoDitherOptions), (IQuantizer)new WuQuantizer(NoDitherOptions),
new HexadecatreeQuantizer(OrderedDitherOptions), (IQuantizer)new HexadecatreeQuantizer(OrderedDitherOptions),
new WebSafePaletteQuantizer(OrderedDitherOptions), (IQuantizer)new WebSafePaletteQuantizer(OrderedDitherOptions),
new WernerPaletteQuantizer(OrderedDitherOptions), (IQuantizer)new WernerPaletteQuantizer(OrderedDitherOptions),
new WuQuantizer(OrderedDitherOptions) (IQuantizer)new WuQuantizer(OrderedDitherOptions)
}; };
public static readonly TheoryData<IQuantizer> DitherScaleQuantizers public static readonly TheoryData<IQuantizer> DitherScaleQuantizers
= new() = new()
{ {
new HexadecatreeQuantizer(Diffuser0_ScaleDitherOptions), (IQuantizer)new HexadecatreeQuantizer(Diffuser0_ScaleDitherOptions),
new WebSafePaletteQuantizer(Diffuser0_ScaleDitherOptions), (IQuantizer)new WebSafePaletteQuantizer(Diffuser0_ScaleDitherOptions),
new WernerPaletteQuantizer(Diffuser0_ScaleDitherOptions), (IQuantizer)new WernerPaletteQuantizer(Diffuser0_ScaleDitherOptions),
new WuQuantizer(Diffuser0_ScaleDitherOptions), (IQuantizer)new WuQuantizer(Diffuser0_ScaleDitherOptions),
new HexadecatreeQuantizer(Diffuser0_25_ScaleDitherOptions), (IQuantizer)new HexadecatreeQuantizer(Diffuser0_25_ScaleDitherOptions),
new WebSafePaletteQuantizer(Diffuser0_25_ScaleDitherOptions), (IQuantizer)new WebSafePaletteQuantizer(Diffuser0_25_ScaleDitherOptions),
new WernerPaletteQuantizer(Diffuser0_25_ScaleDitherOptions), (IQuantizer)new WernerPaletteQuantizer(Diffuser0_25_ScaleDitherOptions),
new WuQuantizer(Diffuser0_25_ScaleDitherOptions), (IQuantizer)new WuQuantizer(Diffuser0_25_ScaleDitherOptions),
new HexadecatreeQuantizer(Diffuser0_5_ScaleDitherOptions), (IQuantizer)new HexadecatreeQuantizer(Diffuser0_5_ScaleDitherOptions),
new WebSafePaletteQuantizer(Diffuser0_5_ScaleDitherOptions), (IQuantizer)new WebSafePaletteQuantizer(Diffuser0_5_ScaleDitherOptions),
new WernerPaletteQuantizer(Diffuser0_5_ScaleDitherOptions), (IQuantizer)new WernerPaletteQuantizer(Diffuser0_5_ScaleDitherOptions),
new WuQuantizer(Diffuser0_5_ScaleDitherOptions), (IQuantizer)new WuQuantizer(Diffuser0_5_ScaleDitherOptions),
new HexadecatreeQuantizer(Diffuser0_75_ScaleDitherOptions), (IQuantizer)new HexadecatreeQuantizer(Diffuser0_75_ScaleDitherOptions),
new WebSafePaletteQuantizer(Diffuser0_75_ScaleDitherOptions), (IQuantizer)new WebSafePaletteQuantizer(Diffuser0_75_ScaleDitherOptions),
new WernerPaletteQuantizer(Diffuser0_75_ScaleDitherOptions), (IQuantizer)new WernerPaletteQuantizer(Diffuser0_75_ScaleDitherOptions),
new WuQuantizer(Diffuser0_75_ScaleDitherOptions), (IQuantizer)new WuQuantizer(Diffuser0_75_ScaleDitherOptions),
new HexadecatreeQuantizer(DiffuserDitherOptions), (IQuantizer)new HexadecatreeQuantizer(DiffuserDitherOptions),
new WebSafePaletteQuantizer(DiffuserDitherOptions), (IQuantizer)new WebSafePaletteQuantizer(DiffuserDitherOptions),
new WernerPaletteQuantizer(DiffuserDitherOptions), (IQuantizer)new WernerPaletteQuantizer(DiffuserDitherOptions),
new WuQuantizer(DiffuserDitherOptions), (IQuantizer)new WuQuantizer(DiffuserDitherOptions),
new HexadecatreeQuantizer(Ordered0_ScaleDitherOptions), (IQuantizer)new HexadecatreeQuantizer(Ordered0_ScaleDitherOptions),
new WebSafePaletteQuantizer(Ordered0_ScaleDitherOptions), (IQuantizer)new WebSafePaletteQuantizer(Ordered0_ScaleDitherOptions),
new WernerPaletteQuantizer(Ordered0_ScaleDitherOptions), (IQuantizer)new WernerPaletteQuantizer(Ordered0_ScaleDitherOptions),
new WuQuantizer(Ordered0_ScaleDitherOptions), (IQuantizer)new WuQuantizer(Ordered0_ScaleDitherOptions),
new HexadecatreeQuantizer(Ordered0_25_ScaleDitherOptions), (IQuantizer)new HexadecatreeQuantizer(Ordered0_25_ScaleDitherOptions),
new WebSafePaletteQuantizer(Ordered0_25_ScaleDitherOptions), (IQuantizer)new WebSafePaletteQuantizer(Ordered0_25_ScaleDitherOptions),
new WernerPaletteQuantizer(Ordered0_25_ScaleDitherOptions), (IQuantizer)new WernerPaletteQuantizer(Ordered0_25_ScaleDitherOptions),
new WuQuantizer(Ordered0_25_ScaleDitherOptions), (IQuantizer)new WuQuantizer(Ordered0_25_ScaleDitherOptions),
new HexadecatreeQuantizer(Ordered0_5_ScaleDitherOptions), (IQuantizer)new HexadecatreeQuantizer(Ordered0_5_ScaleDitherOptions),
new WebSafePaletteQuantizer(Ordered0_5_ScaleDitherOptions), (IQuantizer)new WebSafePaletteQuantizer(Ordered0_5_ScaleDitherOptions),
new WernerPaletteQuantizer(Ordered0_5_ScaleDitherOptions), (IQuantizer)new WernerPaletteQuantizer(Ordered0_5_ScaleDitherOptions),
new WuQuantizer(Ordered0_5_ScaleDitherOptions), (IQuantizer)new WuQuantizer(Ordered0_5_ScaleDitherOptions),
new HexadecatreeQuantizer(Ordered0_75_ScaleDitherOptions), (IQuantizer)new HexadecatreeQuantizer(Ordered0_75_ScaleDitherOptions),
new WebSafePaletteQuantizer(Ordered0_75_ScaleDitherOptions), (IQuantizer)new WebSafePaletteQuantizer(Ordered0_75_ScaleDitherOptions),
new WernerPaletteQuantizer(Ordered0_75_ScaleDitherOptions), (IQuantizer)new WernerPaletteQuantizer(Ordered0_75_ScaleDitherOptions),
new WuQuantizer(Ordered0_75_ScaleDitherOptions), (IQuantizer)new WuQuantizer(Ordered0_75_ScaleDitherOptions),
new HexadecatreeQuantizer(OrderedDitherOptions), (IQuantizer)new HexadecatreeQuantizer(OrderedDitherOptions),
new WebSafePaletteQuantizer(OrderedDitherOptions), (IQuantizer)new WebSafePaletteQuantizer(OrderedDitherOptions),
new WernerPaletteQuantizer(OrderedDitherOptions), (IQuantizer)new WernerPaletteQuantizer(OrderedDitherOptions),
new WuQuantizer(OrderedDitherOptions), (IQuantizer)new WuQuantizer(OrderedDitherOptions),
}; };
public static readonly TheoryData<IDither> DefaultInstanceDitherers public static readonly TheoryData<IDither> DefaultInstanceDitherers
= new() = new()
{ {
default(ErrorDither), (IDither)default(ErrorDither),
default(OrderedDither) (IDither)default(OrderedDither)
}; };
private static readonly ImageComparer ValidatorComparer = ImageComparer.TolerantPercentage(0.05F); private static readonly ImageComparer ValidatorComparer = ImageComparer.TolerantPercentage(0.05F);

1
tests/ImageSharp.Tests/Processing/Processors/Transforms/AffineTransformTests.cs

@ -7,7 +7,6 @@ using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors.Transforms; using SixLabors.ImageSharp.Processing.Processors.Transforms;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.Processing.Transforms; namespace SixLabors.ImageSharp.Tests.Processing.Transforms;

1
tests/ImageSharp.Tests/Processing/Processors/Transforms/ProjectiveTransformTests.cs

@ -9,7 +9,6 @@ using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors.Transforms; using SixLabors.ImageSharp.Processing.Processors.Transforms;
using SixLabors.ImageSharp.Tests.TestUtilities; using SixLabors.ImageSharp.Tests.TestUtilities;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using Xunit.Abstractions;
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms;

1
tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeKernelMapTests.cs

@ -4,7 +4,6 @@
using System.Text; using System.Text;
using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors.Transforms; using SixLabors.ImageSharp.Processing.Processors.Transforms;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms; namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms;

12
tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs

@ -12,20 +12,16 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms;
[GroupOutput("Transforms")] [GroupOutput("Transforms")]
public class RotateTests public class RotateTests
{ {
public static readonly TheoryData<float> RotateAngles public static readonly TheoryData<float> RotateAngles = [50f, -50f, 170f, -170f];
= new()
{
50, -50, 170, -170
};
public static readonly TheoryData<RotateMode> RotateEnumValues public static readonly TheoryData<RotateMode> RotateEnumValues
= new() =
{ [
RotateMode.None, RotateMode.None,
RotateMode.Rotate90, RotateMode.Rotate90,
RotateMode.Rotate180, RotateMode.Rotate180,
RotateMode.Rotate270 RotateMode.Rotate270
}; ];
[Theory] [Theory]
[WithTestPatternImages(nameof(RotateAngles), 100, 50, PixelTypes.Rgba32)] [WithTestPatternImages(nameof(RotateAngles), 100, 50, PixelTypes.Rgba32)]

1
tests/ImageSharp.Tests/ProfilingBenchmarks/LoadResizeSaveProfilingBenchmarks.cs

@ -3,7 +3,6 @@
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.ProfilingBenchmarks; namespace SixLabors.ImageSharp.Tests.ProfilingBenchmarks;

1
tests/ImageSharp.Tests/ProfilingBenchmarks/ResizeProfilingBenchmarks.cs

@ -3,7 +3,6 @@
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.ProfilingBenchmarks; namespace SixLabors.ImageSharp.Tests.ProfilingBenchmarks;

2
tests/ImageSharp.Tests/Quantization/AlphaAssociationQuantizerTests.cs

@ -12,7 +12,7 @@ public class AlphaAssociationQuantizerTests
{ {
public static TheoryData<IDither?> Dithers { get; } = new() public static TheoryData<IDither?> Dithers { get; } = new()
{ {
null, (IDither?)null,
KnownDitherings.Bayer4x4, KnownDitherings.Bayer4x4,
KnownDitherings.FloydSteinberg KnownDitherings.FloydSteinberg
}; };

33
tests/ImageSharp.Tests/TestUtilities/Attributes/ImageDataAttributeBase.cs

@ -3,6 +3,7 @@
using System.Reflection; using System.Reflection;
using Xunit.Sdk; using Xunit.Sdk;
using Xunit.v3;
namespace SixLabors.ImageSharp.Tests; namespace SixLabors.ImageSharp.Tests;
@ -42,11 +43,22 @@ public abstract class ImageDataAttributeBase : DataAttribute
/// </summary> /// </summary>
public Type MemberType { get; set; } public Type MemberType { get; set; }
/// <inheritdoc/>
public override bool SupportsDiscoveryEnumeration() => true;
/// <inheritdoc/>
public override ValueTask<IReadOnlyCollection<ITheoryDataRow>> GetData(MethodInfo testMethod, DisposalTracker disposalTracker)
{
IEnumerable<object[]> rows = this.GetDataRows(testMethod);
IReadOnlyCollection<ITheoryDataRow> result = rows.Select(row => ConvertDataRow(row)).ToList();
return new ValueTask<IReadOnlyCollection<ITheoryDataRow>>(result);
}
/// <summary>Returns the data to be used to test the theory.</summary> /// <summary>Returns the data to be used to test the theory.</summary>
/// <param name="testMethod">The method that is being tested</param> /// <param name="testMethod">The method that is being tested</param>
/// <returns>One or more sets of theory data. Each invocation of the test method /// <returns>One or more sets of theory data. Each invocation of the test method
/// is represented by a single object array.</returns> /// is represented by a single object array.</returns>
public override IEnumerable<object[]> GetData(MethodInfo testMethod) private IEnumerable<object[]> GetDataRows(MethodInfo testMethod)
{ {
IEnumerable<object[]> addedRows = Enumerable.Empty<object[]>().ToArray(); IEnumerable<object[]> addedRows = Enumerable.Empty<object[]>().ToArray();
if (!string.IsNullOrWhiteSpace(this.MemberName)) if (!string.IsNullOrWhiteSpace(this.MemberName))
@ -59,11 +71,22 @@ public abstract class ImageDataAttributeBase : DataAttribute
object obj = accessor(); object obj = accessor();
if (obj is IEnumerable<object> memberItems) if (obj is IEnumerable<object> memberItems)
{ {
addedRows = memberItems.Select(x => x as object[]); // In xunit.v3, TheoryData<T> yields ITheoryDataRow, not object[].
if (addedRows.Any(x => x == null)) // Call GetData to unpack the row's values.
addedRows = memberItems.Select(x =>
{ {
addedRows = memberItems.Select(x => new[] { x }); if (x is ITheoryDataRow row)
} {
return row.GetData();
}
if (x is object[] array)
{
return array;
}
return [x];
});
} }
} }
} }

30
tests/ImageSharp.Tests/TestUtilities/BasicSerializer.cs

@ -2,7 +2,7 @@
// Licensed under the Six Labors Split License. // Licensed under the Six Labors Split License.
using System.ComponentModel; using System.ComponentModel;
using Xunit.Abstractions; using Xunit.Sdk;
namespace SixLabors.ImageSharp.Tests.TestUtilities; namespace SixLabors.ImageSharp.Tests.TestUtilities;
@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities;
/// </summary> /// </summary>
internal class BasicSerializer : IXunitSerializationInfo internal class BasicSerializer : IXunitSerializationInfo
{ {
private readonly Dictionary<string, string> map = []; private readonly Dictionary<string, (string Str, Type Type)> map = [];
public const char Separator = ':'; public const char Separator = ':';
@ -22,9 +22,10 @@ internal class BasicSerializer : IXunitSerializationInfo
using MemoryStream ms = new(); using MemoryStream ms = new();
using StreamWriter writer = new(ms); using StreamWriter writer = new(ms);
writer.WriteLine(type.FullName); writer.WriteLine(type.FullName);
foreach (KeyValuePair<string, string> kv in this.map) foreach (KeyValuePair<string, (string Str, Type Type)> kv in this.map)
{ {
writer.WriteLine($"{kv.Key}{Separator}{kv.Value}"); // Format: key:TypeAssemblyQualifiedName:value
writer.WriteLine($"{kv.Key}{Separator}{kv.Value.Type.AssemblyQualifiedName}{Separator}{kv.Value.Str}");
} }
writer.Flush(); writer.Flush();
@ -41,8 +42,13 @@ internal class BasicSerializer : IXunitSerializationInfo
Type type = Type.GetType(reader.ReadLine()); Type type = Type.GetType(reader.ReadLine());
for (string s = reader.ReadLine(); s != null; s = reader.ReadLine()) for (string s = reader.ReadLine(); s != null; s = reader.ReadLine())
{ {
string[] kv = s.Split(Separator); // Format: key:TypeAssemblyQualifiedName:value
this.map[kv[0]] = kv[1]; string[] parts = s.Split(Separator, 3);
if (parts.Length == 3)
{
Type valueType = Type.GetType(parts[1]) ?? typeof(string);
this.map[parts[0]] = (parts[2], valueType);
}
} }
return type; return type;
@ -76,20 +82,18 @@ internal class BasicSerializer : IXunitSerializationInfo
type ??= value.GetType(); type ??= value.GetType();
this.map[key] = TypeDescriptor.GetConverter(type).ConvertToInvariantString(value); this.map[key] = (TypeDescriptor.GetConverter(type).ConvertToInvariantString(value), type);
} }
public object GetValue(string key, Type type) public object GetValue(string key)
{ {
Guard.NotNull(key, nameof(key)); Guard.NotNull(key, nameof(key));
if (!this.map.TryGetValue(key, out string str)) if (!this.map.TryGetValue(key, out (string Str, Type Type) entry))
{ {
return type.IsValueType ? Activator.CreateInstance(type) : null; return null;
} }
return TypeDescriptor.GetConverter(type).ConvertFromInvariantString(str); return TypeDescriptor.GetConverter(entry.Type).ConvertFromInvariantString(entry.Str);
} }
public T GetValue<T>(string key) => (T)this.GetValue(key, typeof(T));
} }

2
tests/ImageSharp.Tests/TestUtilities/FeatureTesting/FeatureTestRunner.cs

@ -4,7 +4,7 @@
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
using Microsoft.DotNet.RemoteExecutor; using Microsoft.DotNet.RemoteExecutor;
using Xunit.Abstractions; using Xunit.Sdk;
namespace SixLabors.ImageSharp.Tests.TestUtilities; namespace SixLabors.ImageSharp.Tests.TestUtilities;

2
tests/ImageSharp.Tests/TestUtilities/ImageProviders/BasicTestPatternProvider.cs

@ -2,7 +2,7 @@
// Licensed under the Six Labors Split License. // Licensed under the Six Labors Split License.
using System.Numerics; using System.Numerics;
using Xunit.Abstractions; using Xunit.Sdk;
namespace SixLabors.ImageSharp.Tests; namespace SixLabors.ImageSharp.Tests;

3
tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs

@ -2,8 +2,7 @@
// Licensed under the Six Labors Split License. // Licensed under the Six Labors Split License.
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using Xunit.Sdk;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests; namespace SixLabors.ImageSharp.Tests;

3
tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs

@ -6,8 +6,7 @@ using System.Reflection;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using Xunit.Sdk;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests; namespace SixLabors.ImageSharp.Tests;

2
tests/ImageSharp.Tests/TestUtilities/ImageProviders/MemberMethodProvider.cs

@ -3,7 +3,7 @@
using System.Reflection; using System.Reflection;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using Xunit.Abstractions; using Xunit.Sdk;
namespace SixLabors.ImageSharp.Tests; namespace SixLabors.ImageSharp.Tests;

2
tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs

@ -3,7 +3,7 @@
using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using Xunit.Abstractions; using Xunit.Sdk;
namespace SixLabors.ImageSharp.Tests; namespace SixLabors.ImageSharp.Tests;

3
tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs

@ -7,8 +7,7 @@ using Castle.Core.Internal;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing;
using Xunit.Sdk;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests; namespace SixLabors.ImageSharp.Tests;

2
tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs

@ -4,7 +4,7 @@
using System.Numerics; using System.Numerics;
using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using Xunit.Abstractions; using Xunit.Sdk;
namespace SixLabors.ImageSharp.Tests; namespace SixLabors.ImageSharp.Tests;

1
tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs

@ -3,7 +3,6 @@
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests; namespace SixLabors.ImageSharp.Tests;

15
tests/ImageSharp.Tests/TestUtilities/SixLaborsXunitTestFramework.cs

@ -3,22 +3,13 @@
using BenchmarkDotNet.Environments; using BenchmarkDotNet.Environments;
using SixLabors.ImageSharp.Tests.TestUtilities; using SixLabors.ImageSharp.Tests.TestUtilities;
using Xunit.Abstractions; using Xunit.v3;
using Xunit.Sdk;
[assembly: Xunit.TestFramework(SixLaborsXunitTestFramework.Type, SixLaborsXunitTestFramework.Assembly)] [assembly: Xunit.TestFramework(typeof(SixLaborsXunitTestFramework))]
namespace SixLabors.ImageSharp.Tests.TestUtilities; namespace SixLabors.ImageSharp.Tests.TestUtilities;
public class SixLaborsXunitTestFramework : XunitTestFramework public class SixLaborsXunitTestFramework : XunitTestFramework
{ {
public const string Type = "SixLabors.ImageSharp.Tests.TestUtilities.SixLaborsXunitTestFramework"; public SixLaborsXunitTestFramework() => Console.Error.WriteLine(HostEnvironmentInfo.GetInformation());
public const string Assembly = "SixLabors.ImageSharp.Tests";
public SixLaborsXunitTestFramework(IMessageSink messageSink)
: base(messageSink)
{
DiagnosticMessage message = new(HostEnvironmentInfo.GetInformation());
messageSink.OnMessage(message);
}
} }

2
tests/ImageSharp.Tests/TestUtilities/TestPixel.cs

@ -3,7 +3,7 @@
using System.Numerics; using System.Numerics;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using Xunit.Abstractions; using Xunit.Sdk;
namespace SixLabors.ImageSharp.Tests.TestUtilities; namespace SixLabors.ImageSharp.Tests.TestUtilities;

2
tests/ImageSharp.Tests/TestUtilities/TestType.cs

@ -1,7 +1,7 @@
// Copyright (c) Six Labors. // Copyright (c) Six Labors.
// Licensed under the Six Labors Split License. // Licensed under the Six Labors Split License.
using Xunit.Abstractions; using Xunit.Sdk;
namespace SixLabors.ImageSharp.Tests.TestUtilities; namespace SixLabors.ImageSharp.Tests.TestUtilities;

2
tests/ImageSharp.Tests/TestUtilities/TestVector4.cs

@ -2,7 +2,7 @@
// Licensed under the Six Labors Split License. // Licensed under the Six Labors Split License.
using System.Numerics; using System.Numerics;
using Xunit.Abstractions; using Xunit.Sdk;
namespace SixLabors.ImageSharp.Tests.TestUtilities; namespace SixLabors.ImageSharp.Tests.TestUtilities;

24
tests/ImageSharp.Tests/TestUtilities/Tests/BasicSerializerTests.cs

@ -2,7 +2,7 @@
// Licensed under the Six Labors Split License. // Licensed under the Six Labors Split License.
using SixLabors.ImageSharp.Tests.TestUtilities; using SixLabors.ImageSharp.Tests.TestUtilities;
using Xunit.Abstractions; using Xunit.Sdk;
namespace SixLabors.ImageSharp.Tests; namespace SixLabors.ImageSharp.Tests;
@ -18,16 +18,16 @@ public class BasicSerializerTests
public virtual void Deserialize(IXunitSerializationInfo info) public virtual void Deserialize(IXunitSerializationInfo info)
{ {
info.AddValue(nameof(this.Length), this.Length); this.Length = info.GetValue<double>(nameof(this.Length));
info.AddValue(nameof(this.Name), this.Name); this.Name = info.GetValue<string>(nameof(this.Name));
info.AddValue(nameof(this.Lives), this.Lives); this.Lives = info.GetValue<int>(nameof(this.Lives));
} }
public virtual void Serialize(IXunitSerializationInfo info) public virtual void Serialize(IXunitSerializationInfo info)
{ {
this.Length = info.GetValue<double>(nameof(this.Length)); info.AddValue(nameof(this.Length), this.Length);
this.Name = info.GetValue<string>(nameof(this.Name)); info.AddValue(nameof(this.Name), this.Name);
this.Lives = info.GetValue<int>(nameof(this.Lives)); info.AddValue(nameof(this.Lives), this.Lives);
} }
} }
@ -37,8 +37,8 @@ public class BasicSerializerTests
public override void Deserialize(IXunitSerializationInfo info) public override void Deserialize(IXunitSerializationInfo info)
{ {
this.Strength = info.GetValue<double>(nameof(this.Strength));
base.Deserialize(info); base.Deserialize(info);
this.Strength = info.GetValue<double>(nameof(this.Strength));
} }
public override void Serialize(IXunitSerializationInfo info) public override void Serialize(IXunitSerializationInfo info)
@ -51,7 +51,13 @@ public class BasicSerializerTests
[Fact] [Fact]
public void SerializeDeserialize_ShouldPreserveValues() public void SerializeDeserialize_ShouldPreserveValues()
{ {
DerivedObj obj = new() { Length = 123.1, Name = "Lol123!", Lives = 7, Strength = 4.8 }; DerivedObj obj = new()
{
Length = 123.1,
Name = "Lol123!",
Lives = 7,
Strength = 4.8,
};
string str = BasicSerializer.Serialize(obj); string str = BasicSerializer.Serialize(obj);
BaseObj mirrorBase = BasicSerializer.Deserialize<BaseObj>(str); BaseObj mirrorBase = BasicSerializer.Deserialize<BaseObj>(str);

2
tests/ImageSharp.Tests/TestUtilities/Tests/FeatureTestRunnerTests.cs

@ -4,7 +4,7 @@
using System.Numerics; using System.Numerics;
using System.Runtime.Intrinsics.Arm; using System.Runtime.Intrinsics.Arm;
using System.Runtime.Intrinsics.X86; using System.Runtime.Intrinsics.X86;
using Xunit.Abstractions; using Xunit.Sdk;
using Aes = System.Runtime.Intrinsics.X86.Aes; using Aes = System.Runtime.Intrinsics.X86.Aes;
namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests; namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests;

1
tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs

@ -5,7 +5,6 @@ using Moq;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests; namespace SixLabors.ImageSharp.Tests;

1
tests/ImageSharp.Tests/TestUtilities/Tests/MagickReferenceCodecTests.cs

@ -5,7 +5,6 @@ using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs; using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests; namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests;

1
tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs

@ -4,7 +4,6 @@
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs; using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests; namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests;

1
tests/ImageSharp.Tests/TestUtilities/Tests/SystemDrawingReferenceCodecTests.cs

@ -8,7 +8,6 @@ using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison; using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs; using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests; namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests;

1
tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs

@ -9,7 +9,6 @@ using SixLabors.ImageSharp.Formats.Gif;
using SixLabors.ImageSharp.Formats.Jpeg; using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.Formats.Webp; using SixLabors.ImageSharp.Formats.Webp;
using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs; using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs;
using Xunit.Abstractions;
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests; namespace SixLabors.ImageSharp.Tests;

23
tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs

@ -8,24 +8,25 @@ using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.Metadata; using SixLabors.ImageSharp.Metadata;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs; using SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs;
using Xunit.Abstractions;
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests; namespace SixLabors.ImageSharp.Tests;
public class TestImageProviderTests public class TestImageProviderTests
{ {
public static readonly TheoryData<object> BasicData = new() public static readonly TheoryData<object> BasicData = new(
{ new object[]
TestImageProvider<Rgba32>.Blank(10, 20), {
TestImageProvider<HalfVector4>.Blank(10, 20), TestImageProvider<Rgba32>.Blank(10, 20),
}; TestImageProvider<HalfVector4>.Blank(10, 20),
});
public static readonly TheoryData<object> FileData = new() public static readonly TheoryData<object> FileData = new(
{ new object[]
TestImageProvider<Rgba32>.File(TestImages.Bmp.Car), {
TestImageProvider<HalfVector4>.File(TestImages.Bmp.F) TestImageProvider<Rgba32>.File(TestImages.Bmp.Car),
}; TestImageProvider<HalfVector4>.File(TestImages.Bmp.F),
});
public static string[] AllBmpFiles = [TestImages.Bmp.F, TestImages.Bmp.Bit8]; public static string[] AllBmpFiles = [TestImages.Bmp.F, TestImages.Bmp.Bit8];

1
tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs

@ -5,7 +5,6 @@ using System.Numerics;
using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests; namespace SixLabors.ImageSharp.Tests;

12
tests/ImageSharp.Tests/TestUtilities/XUnit/ConditionalDiscovererException.cs

@ -0,0 +1,12 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace Microsoft.DotNet.XUnitExtensions;
internal class ConditionalDiscovererException : Exception
{
public ConditionalDiscovererException(string message)
: base(message)
{
}
}

35
tests/ImageSharp.Tests/TestUtilities/XUnit/ConditionalFact.cs

@ -0,0 +1,35 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics.CodeAnalysis;
using Microsoft.DotNet.XUnitExtensions;
using XUnit;
namespace Xunit;
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public sealed class ConditionalFactAttribute : FactAttribute
{
[DynamicallyAccessedMembers(StaticReflectionConstants.ConditionalMemberKinds)]
public Type CalleeType { get; private set; }
public string[] ConditionMemberNames { get; private set; }
public ConditionalFactAttribute(
[DynamicallyAccessedMembers(StaticReflectionConstants.ConditionalMemberKinds)]
Type calleeType,
params string[] conditionMemberNames)
{
this.CalleeType = calleeType;
this.ConditionMemberNames = conditionMemberNames;
string skipReason = ConditionalTestDiscoverer.EvaluateSkipConditions(calleeType, conditionMemberNames);
if (skipReason != null)
{
this.Skip = skipReason;
}
}
[Obsolete(
"Use the overload that takes a Type parameter: ConditionalFact(typeof(MyClass), nameof(MyCondition)).")]
public ConditionalFactAttribute(params string[] conditionMemberNames) => this.ConditionMemberNames = conditionMemberNames;
}

154
tests/ImageSharp.Tests/TestUtilities/XUnit/ConditionalTestDiscoverer.cs

@ -0,0 +1,154 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using Xunit.Sdk;
namespace Microsoft.DotNet.XUnitExtensions;
// Internal helper class for code common to conditional test discovery through
// [ConditionalFact] and [ConditionalTheory]
internal static class ConditionalTestDiscoverer
{
/// <summary>
/// Evaluates skip conditions given an explicit callee type and condition member names.
/// Used by attribute constructors in xunit v3 where discoverers are not needed.
/// </summary>
internal static string EvaluateSkipConditions([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type calleeType, string[] conditionMemberNames)
{
if (
calleeType == null
|| conditionMemberNames == null
|| conditionMemberNames.Length == 0)
{
return null;
}
List<string> falseConditions = new(conditionMemberNames.Length);
foreach (string entry in conditionMemberNames)
{
if (string.IsNullOrWhiteSpace(entry))
{
continue;
}
Func<bool> conditionFunc = LookupConditionalMember(calleeType, entry);
if (conditionFunc == null)
{
throw new ConditionalDiscovererException(
GetFailedLookupString(entry, calleeType));
}
try
{
if (!conditionFunc())
{
falseConditions.Add(entry);
}
}
catch (Exception exc)
{
falseConditions.Add($"{entry} ({exc.GetType().Name})");
}
}
return falseConditions.Count > 0
? $"Condition(s) not met: \"{string.Join("\", \"", falseConditions)}\""
: null;
}
internal static string GetFailedLookupString(string name, Type type) =>
$"An appropriate member '{name}' could not be found. "
+ $"The conditional method needs to be a static method, property, or field on the type {type} or any ancestor, "
+ "of any visibility, accepting zero arguments, and having a return type of Boolean.";
internal static Func<bool> LookupConditionalMember(Type t, string name)
{
if (t == null || name == null)
{
return null;
}
TypeInfo ti = t.GetTypeInfo();
MethodInfo mi = ti.GetDeclaredMethod(name);
if (
mi != null
&& mi.IsStatic
&& mi.GetParameters().Length == 0
&& mi.ReturnType == typeof(bool))
{
return () => (bool)mi.Invoke(null, null);
}
PropertyInfo pi = ti.GetDeclaredProperty(name);
if (
pi != null
&& pi.PropertyType == typeof(bool)
&& pi.GetMethod != null
&& pi.GetMethod.IsStatic
&& pi.GetMethod.GetParameters().Length == 0)
{
return () => (bool)pi.GetValue(null);
}
FieldInfo fi = ti.GetDeclaredField(name);
if (fi != null && fi.FieldType == typeof(bool) && fi.IsStatic)
{
return () => (bool)fi.GetValue(null);
}
return LookupConditionalMember(ti.BaseType, name);
}
internal static bool CheckInputToSkipExecution(
object[] conditionArguments,
ref Type calleeType,
ref string[] conditionMemberNames,
object testMethod = null)
{
// A null or empty list of conditionArguments is treated as "no conditions".
// and the test cases will be executed.
// Example: [ConditionalClass()]
if (conditionArguments == null || conditionArguments.Length == 0)
{
return true;
}
calleeType = conditionArguments[0] as Type;
if (calleeType != null)
{
if (conditionArguments.Length < 2)
{
// [ConditionalFact(typeof(x))] no provided methods.
return true;
}
// [ConditionalFact(typeof(x), "MethodName")]
conditionMemberNames = conditionArguments[1] as string[];
}
else
{
// For [ConditionalClass], unable to get the Type info. All test cases will be executed.
if (testMethod == null)
{
return true;
}
// [ConditionalFact("MethodName")]
conditionMemberNames = conditionArguments[0] as string[];
}
// [ConditionalFact((string[]) null)]
if (conditionMemberNames == null || conditionMemberNames.Count() == 0)
{
return true;
}
return false;
}
}

33
tests/ImageSharp.Tests/TestUtilities/XUnit/ConditionalTheory.cs

@ -0,0 +1,33 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics.CodeAnalysis;
using Microsoft.DotNet.XUnitExtensions;
namespace XUnit;
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public sealed class ConditionalTheoryAttribute: TheoryAttribute
{
[DynamicallyAccessedMembers(StaticReflectionConstants.ConditionalMemberKinds)]
public Type CalleeType { get; private set; }
public string[] ConditionMemberNames { get; private set; }
public ConditionalTheoryAttribute([DynamicallyAccessedMembers(StaticReflectionConstants.ConditionalMemberKinds)] Type calleeType, params string[] conditionMemberNames)
{
this.CalleeType = calleeType;
this.ConditionMemberNames = conditionMemberNames;
string skipReason = ConditionalTestDiscoverer.EvaluateSkipConditions(calleeType, conditionMemberNames);
if (skipReason != null)
{
this.Skip = skipReason;
}
}
[Obsolete("Use the overload that takes a Type parameter: ConditionalTheory(typeof(MyClass), nameof(MyCondition)).")]
public ConditionalTheoryAttribute(params string[] conditionMemberNames) => this.ConditionMemberNames = conditionMemberNames;
}

15
tests/ImageSharp.Tests/TestUtilities/XUnit/StaticReflectionConstants.cs

@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics.CodeAnalysis;
namespace XUnit;
internal static class StaticReflectionConstants
{
// ConditionalTestDiscoverer looks at all fields/methods/properties recursively.
public const DynamicallyAccessedMemberTypes ConditionalMemberKinds =
DynamicallyAccessedMemberTypes.PublicConstructors |
DynamicallyAccessedMemberTypes.PublicMethods |
DynamicallyAccessedMemberTypes.PublicProperties;
}

6
tests/ImageSharp.Tests/ValidateDisposedMemoryAllocationsAttribute.cs

@ -2,7 +2,7 @@
// Licensed under the Six Labors Split License. // Licensed under the Six Labors Split License.
using System.Reflection; using System.Reflection;
using Xunit.Sdk; using Xunit.v3;
namespace SixLabors.ImageSharp.Tests; namespace SixLabors.ImageSharp.Tests;
@ -19,10 +19,10 @@ public class ValidateDisposedMemoryAllocationsAttribute : BeforeAfterTestAttribu
public ValidateDisposedMemoryAllocationsAttribute(int expected) public ValidateDisposedMemoryAllocationsAttribute(int expected)
=> this.expected = expected; => this.expected = expected;
public override void Before(MethodInfo methodUnderTest) public override void Before(MethodInfo methodUnderTest, IXunitTest test)
=> MemoryAllocatorValidator.MonitorAllocations(); => MemoryAllocatorValidator.MonitorAllocations();
public override void After(MethodInfo methodUnderTest) public override void After(MethodInfo methodUnderTest, IXunitTest test)
{ {
MemoryAllocatorValidator.ValidateAllocations(this.expected); MemoryAllocatorValidator.ValidateAllocations(this.expected);
MemoryAllocatorValidator.StopMonitoringAllocations(); MemoryAllocatorValidator.StopMonitoringAllocations();

Loading…
Cancel
Save