diff --git a/tests/ImageSharp.Tests/Common/BufferTests.cs b/tests/ImageSharp.Tests/Common/BufferTests.cs index 010bf40b3..25ef173d4 100644 --- a/tests/ImageSharp.Tests/Common/BufferTests.cs +++ b/tests/ImageSharp.Tests/Common/BufferTests.cs @@ -163,7 +163,7 @@ namespace ImageSharp.Tests.Common // Assert.Equal(buffer.Array, span.ToArray()); // Assert.Equal(0, span.Start); Assert.SpanPointsTo(span, buffer); - Assert.Equal(span.Length, 42); + Assert.Equal(42, span.Length); } } diff --git a/tests/ImageSharp.Tests/Common/ConstantsTests.cs b/tests/ImageSharp.Tests/Common/ConstantsTests.cs index 0adda0c0f..be4addf91 100644 --- a/tests/ImageSharp.Tests/Common/ConstantsTests.cs +++ b/tests/ImageSharp.Tests/Common/ConstantsTests.cs @@ -12,7 +12,7 @@ namespace ImageSharp.Tests.Common [Fact] public void Epsilon() { - Assert.Equal(Constants.Epsilon, 0.001f); + Assert.Equal(0.001f, Constants.Epsilon); } } } diff --git a/tests/ImageSharp.Tests/Drawing/Text/TextGraphicsOptionsTests.cs b/tests/ImageSharp.Tests/Drawing/Text/TextGraphicsOptionsTests.cs index a291a7d18..1a26bcfed 100644 --- a/tests/ImageSharp.Tests/Drawing/Text/TextGraphicsOptionsTests.cs +++ b/tests/ImageSharp.Tests/Drawing/Text/TextGraphicsOptionsTests.cs @@ -22,7 +22,7 @@ namespace ImageSharp.Tests.Drawing.Text TextGraphicsOptions textOptions = opt; - Assert.Equal(false, textOptions.Antialias); + Assert.False(textOptions.Antialias); Assert.Equal(99, textOptions.AntialiasSubpixelDepth); } @@ -36,7 +36,7 @@ namespace ImageSharp.Tests.Drawing.Text GraphicsOptions opt = (GraphicsOptions)textOptions; - Assert.Equal(false, opt.Antialias); + Assert.False(opt.Antialias); Assert.Equal(99, opt.AntialiasSubpixelDepth); } } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs index aac3f4611..f3412e45e 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs @@ -34,7 +34,7 @@ namespace ImageSharp.Tests }; // [Theory] // Benchmark, enable manually - [MemberData(nameof(DecodeJpegData))] + // [MemberData(nameof(DecodeJpegData))] public void DecodeJpeg(string fileName) { const int ExecutionCount = 30; @@ -60,10 +60,10 @@ namespace ImageSharp.Tests // Benchmark, enable manually! // [Theory] - [InlineData(1, 75, JpegSubsample.Ratio420)] - [InlineData(30, 75, JpegSubsample.Ratio420)] - [InlineData(30, 75, JpegSubsample.Ratio444)] - [InlineData(30, 100, JpegSubsample.Ratio444)] + // [InlineData(1, 75, JpegSubsample.Ratio420)] + // [InlineData(30, 75, JpegSubsample.Ratio420)] + // [InlineData(30, 75, JpegSubsample.Ratio444)] + // [InlineData(30, 100, JpegSubsample.Ratio444)] public void EncodeJpeg(int executionCount, int quality, JpegSubsample subsample) { string[] testFiles = TestImages.Bmp.All diff --git a/tests/ImageSharp.Tests/Formats/Jpg/YCbCrImageTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/YCbCrImageTests.cs index f207dc1d1..b7cd281cd 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/YCbCrImageTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/YCbCrImageTests.cs @@ -19,11 +19,6 @@ namespace ImageSharp.Tests private ITestOutputHelper Output { get; } - private void PrintChannel(string name, JpegPixelArea channel) - { - this.Output.WriteLine($"{name}: Stride={channel.Stride}"); - } - [Theory] [InlineData(YCbCrImage.YCbCrSubsampleRatio.YCbCrSubsampleRatio410, 4, 2)] [InlineData(YCbCrImage.YCbCrSubsampleRatio.YCbCrSubsampleRatio411, 4, 1)] @@ -31,7 +26,10 @@ namespace ImageSharp.Tests [InlineData(YCbCrImage.YCbCrSubsampleRatio.YCbCrSubsampleRatio422, 2, 1)] [InlineData(YCbCrImage.YCbCrSubsampleRatio.YCbCrSubsampleRatio440, 1, 2)] [InlineData(YCbCrImage.YCbCrSubsampleRatio.YCbCrSubsampleRatio444, 1, 1)] - internal void CalculateChrominanceSize(YCbCrImage.YCbCrSubsampleRatio ratioValue, int expectedDivX, int expectedDivY) + internal void CalculateChrominanceSize( + YCbCrImage.YCbCrSubsampleRatio ratioValue, + int expectedDivX, + int expectedDivY) { YCbCrImage.YCbCrSubsampleRatio ratio = (YCbCrImage.YCbCrSubsampleRatio)ratioValue; @@ -39,7 +37,7 @@ namespace ImageSharp.Tests Size size = YCbCrImage.CalculateChrominanceSize(400, 400, ratio); //this.Output.WriteLine($"Ch Size: {size}"); - Assert.Equal(new Size(400/expectedDivX, 400/expectedDivY), size); + Assert.Equal(new Size(400 / expectedDivX, 400 / expectedDivY), size); } [Theory] @@ -61,10 +59,14 @@ namespace ImageSharp.Tests //this.PrintChannel("Cb", img.CbChannel); //this.PrintChannel("Cr", img.CrChannel); - Assert.Equal(img.YChannel.Width, 400); + Assert.Equal(400, img.YChannel.Width); Assert.Equal(img.CbChannel.Width, 400 / expectedCStrideDiv); Assert.Equal(img.CrChannel.Width, 400 / expectedCStrideDiv); } + private void PrintChannel(string name, JpegPixelArea channel) + { + this.Output.WriteLine($"{name}: Stride={channel.Stride}"); + } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/IO/BigEndianBitConverter.ToTypeTests.cs b/tests/ImageSharp.Tests/IO/BigEndianBitConverter.ToTypeTests.cs index 50a86d3cc..a69727d45 100644 --- a/tests/ImageSharp.Tests/IO/BigEndianBitConverter.ToTypeTests.cs +++ b/tests/ImageSharp.Tests/IO/BigEndianBitConverter.ToTypeTests.cs @@ -56,13 +56,13 @@ namespace ImageSharp.Tests.IO [Fact] public void ToBoolean() { - Assert.Equal(false, EndianBitConverter.BigEndianConverter.ToBoolean(new byte[] { 0 }, 0)); - Assert.Equal(true, EndianBitConverter.BigEndianConverter.ToBoolean(new byte[] { 1 }, 0)); - Assert.Equal(true, EndianBitConverter.BigEndianConverter.ToBoolean(new byte[] { 42 }, 0)); + Assert.False(EndianBitConverter.BigEndianConverter.ToBoolean(new byte[] { 0 }, 0)); + Assert.True(EndianBitConverter.BigEndianConverter.ToBoolean(new byte[] { 1 }, 0)); + Assert.True(EndianBitConverter.BigEndianConverter.ToBoolean(new byte[] { 42 }, 0)); - Assert.Equal(false, EndianBitConverter.BigEndianConverter.ToBoolean(new byte[] { 1, 0 }, 1)); - Assert.Equal(true, EndianBitConverter.BigEndianConverter.ToBoolean(new byte[] { 0, 1 }, 1)); - Assert.Equal(true, EndianBitConverter.BigEndianConverter.ToBoolean(new byte[] { 0, 42 }, 1)); + Assert.False(EndianBitConverter.BigEndianConverter.ToBoolean(new byte[] { 1, 0 }, 1)); + Assert.True(EndianBitConverter.BigEndianConverter.ToBoolean(new byte[] { 0, 1 }, 1)); + Assert.True(EndianBitConverter.BigEndianConverter.ToBoolean(new byte[] { 0, 42 }, 1)); } /// diff --git a/tests/ImageSharp.Tests/IO/LittleEndianBitConverter.ToTypeTests.cs b/tests/ImageSharp.Tests/IO/LittleEndianBitConverter.ToTypeTests.cs index fa8b2a1a2..c46c011a1 100644 --- a/tests/ImageSharp.Tests/IO/LittleEndianBitConverter.ToTypeTests.cs +++ b/tests/ImageSharp.Tests/IO/LittleEndianBitConverter.ToTypeTests.cs @@ -56,11 +56,11 @@ namespace ImageSharp.Tests.IO [Fact] public void ToBoolean() { - Assert.Equal(false, EndianBitConverter.LittleEndianConverter.ToBoolean(new byte[] { 0 }, 0)); - Assert.Equal(true, EndianBitConverter.LittleEndianConverter.ToBoolean(new byte[] { 1 }, 0)); + Assert.False(EndianBitConverter.LittleEndianConverter.ToBoolean(new byte[] { 0 }, 0)); + Assert.True(EndianBitConverter.LittleEndianConverter.ToBoolean(new byte[] { 1 }, 0)); - Assert.Equal(false, EndianBitConverter.LittleEndianConverter.ToBoolean(new byte[] { 1, 0 }, 1)); - Assert.Equal(true, EndianBitConverter.LittleEndianConverter.ToBoolean(new byte[] { 0, 1 }, 1)); + Assert.False(EndianBitConverter.LittleEndianConverter.ToBoolean(new byte[] { 1, 0 }, 1)); + Assert.True(EndianBitConverter.LittleEndianConverter.ToBoolean(new byte[] { 0, 1 }, 1)); } /// diff --git a/tests/ImageSharp.Tests/MetaData/ImagePropertyTests.cs b/tests/ImageSharp.Tests/MetaData/ImagePropertyTests.cs index 8b4c6ea10..3b224014d 100644 --- a/tests/ImageSharp.Tests/MetaData/ImagePropertyTests.cs +++ b/tests/ImageSharp.Tests/MetaData/ImagePropertyTests.cs @@ -25,7 +25,7 @@ namespace ImageSharp.Tests Assert.Equal(property1, property2); Assert.True(property1 == property2); - Assert.Equal(property3, null); + Assert.Null(property3); } /// @@ -41,7 +41,7 @@ namespace ImageSharp.Tests Assert.False(property1.Equals("Foo")); - Assert.NotEqual(property1, null); + Assert.NotNull(property1); Assert.NotEqual(property1, property2); Assert.True(property1 != property2); @@ -69,7 +69,7 @@ namespace ImageSharp.Tests { ImageProperty property = new ImageProperty("Foo", null); Assert.Equal("Foo", property.Name); - Assert.Equal(null, property.Value); + Assert.Null(property.Value); property = new ImageProperty("Foo", string.Empty); Assert.Equal(string.Empty, property.Value); diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifValueTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifValueTests.cs index a91eb310d..473af7712 100644 --- a/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifValueTests.cs +++ b/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifValueTests.cs @@ -44,7 +44,7 @@ namespace ImageSharp.Tests Assert.Equal(ExifDataType.Ascii, value.DataType); Assert.Equal(ExifTag.GPSDOP, value.Tag); - Assert.Equal(false, value.IsArray); + Assert.False(value.IsArray); Assert.Equal("Windows Photo Editor 10.0.10011.16384", value.ToString()); Assert.Equal("Windows Photo Editor 10.0.10011.16384", value.Value); } diff --git a/tests/ImageSharp.Tests/Numerics/RectangleFTests.cs b/tests/ImageSharp.Tests/Numerics/RectangleFTests.cs index b20b660dd..78fbc68f6 100644 --- a/tests/ImageSharp.Tests/Numerics/RectangleFTests.cs +++ b/tests/ImageSharp.Tests/Numerics/RectangleFTests.cs @@ -256,6 +256,7 @@ namespace ImageSharp.Tests Assert.Equal(string.Format(CultureInfo.CurrentCulture, "RectangleF [ X={0}, Y={1}, Width={2}, Height={3} ]", r.X, r.Y, r.Width, r.Height), r.ToString()); } + [Theory] [InlineData(0, 0, 0, 0)] [InlineData(5, -5, 0.2, -1.3)] public void ToStringTestEmpty(float x, float y, float width, float height) diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs index dcb75245d..13f67fc27 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs @@ -1,3 +1,4 @@ +// ReSharper disable InconsistentNaming namespace ImageSharp.Tests { using ImageSharp.PixelFormats; @@ -19,6 +20,7 @@ namespace ImageSharp.Tests Assert.Equal(g, p.G); Assert.Equal(b, p.B); } + [Fact] public unsafe void ByteLayoutIsSequentialBgr() { @@ -30,34 +32,29 @@ namespace ImageSharp.Tests Assert.Equal(1, ptr[2]); } - public class Equality + [Theory] + [MemberData(nameof(ColorData))] + public void Equals_WhenTrue(byte r, byte g, byte b) { - public static TheoryData ColorData = Rgb24Tests.ColorData; - - [Theory] - [MemberData(nameof(ColorData))] - public void WhenTrue(byte r, byte g, byte b) - { - var x = new Rgb24(r, g, b); - var y = new Rgb24(r, g, b); - - Assert.True(x.Equals(y)); - Assert.True(x.Equals((object)y)); - Assert.Equal(x.GetHashCode(), y.GetHashCode()); - } - - [Theory] - [InlineData(1, 2, 3, 1, 2, 4)] - [InlineData(0, 255, 0, 0, 244, 0)] - [InlineData(1, 255, 0, 0, 255, 0)] - public void WhenFalse(byte r1, byte g1, byte b1, byte r2, byte g2, byte b2) - { - var a = new Rgb24(r1, g1, b1); - var b = new Rgb24(r2, g2, b2); - - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)b)); - } + var x = new Rgb24(r, g, b); + var y = new Rgb24(r, g, b); + + Assert.True(x.Equals(y)); + Assert.True(x.Equals((object)y)); + Assert.Equal(x.GetHashCode(), y.GetHashCode()); + } + + [Theory] + [InlineData(1, 2, 3, 1, 2, 4)] + [InlineData(0, 255, 0, 0, 244, 0)] + [InlineData(1, 255, 0, 0, 255, 0)] + public void Equals_WhenFalse(byte r1, byte g1, byte b1, byte r2, byte g2, byte b2) + { + var a = new Rgb24(r1, g1, b1); + var b = new Rgb24(r2, g2, b2); + + Assert.False(a.Equals(b)); + Assert.False(a.Equals((object)b)); } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs index 82be9e810..1ff91a2b1 100644 --- a/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs @@ -1,3 +1,4 @@ +// ReSharper disable InconsistentNaming namespace ImageSharp.Tests { using ImageSharp.PixelFormats; @@ -36,35 +37,30 @@ namespace ImageSharp.Tests Assert.Equal(4, ptr[3]); } - public class Equality + [Theory] + [MemberData(nameof(ColorData))] + public void Equality_WhenTrue(byte b, byte g, byte r, byte a) { - public static TheoryData ColorData = Bgra32Tests.ColorData; - - [Theory] - [MemberData(nameof(ColorData))] - public void WhenTrue(byte b, byte g, byte r, byte a) - { - var x = new Bgra32(r, g, b, a); - var y = new Bgra32(r, g, b, a); + var x = new Bgra32(r, g, b, a); + var y = new Bgra32(r, g, b, a); - Assert.True(x.Equals(y)); - Assert.True(x.Equals((object)y)); - Assert.Equal(x.GetHashCode(), y.GetHashCode()); - } + Assert.True(x.Equals(y)); + Assert.True(x.Equals((object)y)); + Assert.Equal(x.GetHashCode(), y.GetHashCode()); + } - [Theory] - [InlineData(1, 2, 3, 4, 1, 2, 3, 5)] - [InlineData(0, 0, 255, 0, 0, 0, 244, 0)] - [InlineData(0, 255, 0, 0, 0, 244, 0, 0)] - [InlineData(1, 255, 0, 0, 0, 255, 0, 0)] - public void WhenFalse(byte b1, byte g1, byte r1, byte a1, byte b2, byte g2, byte r2, byte a2) - { - var x = new Bgra32(r1, g1, b1, a1); - var y = new Bgra32(r2, g2, b2, a2); + [Theory] + [InlineData(1, 2, 3, 4, 1, 2, 3, 5)] + [InlineData(0, 0, 255, 0, 0, 0, 244, 0)] + [InlineData(0, 255, 0, 0, 0, 244, 0, 0)] + [InlineData(1, 255, 0, 0, 0, 255, 0, 0)] + public void Equality_WhenFalse(byte b1, byte g1, byte r1, byte a1, byte b2, byte g2, byte r2, byte a2) + { + var x = new Bgra32(r1, g1, b1, a1); + var y = new Bgra32(r2, g2, b2, a2); - Assert.False(x.Equals(y)); - Assert.False(x.Equals((object)y)); - } + Assert.False(x.Equals(y)); + Assert.False(x.Equals((object)y)); } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/PixelFormats/PackedPixelTests.cs b/tests/ImageSharp.Tests/PixelFormats/PackedPixelTests.cs index dad426c40..773bfa513 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PackedPixelTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PackedPixelTests.cs @@ -40,10 +40,10 @@ namespace ImageSharp.Tests.Colors // Test ordering Vector4 vector = new Alpha8(.5F).ToVector4(); - Assert.Equal(vector.X, 0); - Assert.Equal(vector.Y, 0); - Assert.Equal(vector.Z, 0); - Assert.Equal(vector.W, .5F, 2); + Assert.Equal(0, vector.X); + Assert.Equal(0, vector.Y); + Assert.Equal(0, vector.Z); + Assert.Equal(.5F, vector.W, 2); byte[] rgb = new byte[3]; byte[] rgba = new byte[4]; diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs index fa7d9d247..76475388d 100644 --- a/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs @@ -43,8 +43,11 @@ namespace ImageSharp.Tests.PixelFormats ); } + // [Fact] // Profiling benchmark - enable manually! +#pragma warning disable xUnit1013 // Public method should be marked as test public void Benchmark_ToVector4() +#pragma warning restore xUnit1013 // Public method should be marked as test { int times = 200000; int count = 1024; diff --git a/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs b/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs index 666f3df78..7caa1e7c0 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs @@ -26,7 +26,7 @@ namespace ImageSharp.Tests.Processing.Transforms { for (int x = 0; x < 25; x++) { - Assert.Equal(image[x, y], default(TPixel)); + Assert.Equal(default(TPixel), image[x, y]); } } } diff --git a/tests/ImageSharp.Tests/Processing/Transforms/ResizeProfilingBenchmarks.cs b/tests/ImageSharp.Tests/Processing/Transforms/ResizeProfilingBenchmarks.cs index 8b57586f4..a300672e8 100644 --- a/tests/ImageSharp.Tests/Processing/Transforms/ResizeProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/Processing/Transforms/ResizeProfilingBenchmarks.cs @@ -25,8 +25,8 @@ namespace ImageSharp.Tests.Processing.Transforms public int ExecutionCount { get; set; } = 50; // [Theory] // Benchmark, enable manually! - [InlineData(100, 100)] - [InlineData(2000, 2000)] + // [InlineData(100, 100)] + // [InlineData(2000, 2000)] public void ResizeBicubic(int width, int height) { this.Measure(this.ExecutionCount, diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs index 6bd5b392d..c01babb63 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs @@ -103,8 +103,8 @@ namespace ImageSharp.Tests where TPixel : struct, IPixel { Image img = provider.GetImage(); - Assert.Equal(img.Width, 10); - Assert.Equal(img.Height, 20); + Assert.Equal(10, img.Width); + Assert.Equal(20, img.Height); byte[] colors = new byte[4]; @@ -116,10 +116,10 @@ namespace ImageSharp.Tests { pixels[x, y].ToXyzwBytes(colors, 0); - Assert.Equal(colors[0], 255); - Assert.Equal(colors[1], 100); - Assert.Equal(colors[2], 50); - Assert.Equal(colors[3], 200); + Assert.Equal(255, colors[0]); + Assert.Equal(100, colors[1]); + Assert.Equal(50, colors[2]); + Assert.Equal(200, colors[3]); } } } @@ -143,7 +143,7 @@ namespace ImageSharp.Tests where TPixel : struct, IPixel { Image img = provider.GetImage(); - Assert.Equal(img.Width, 3); + Assert.Equal(3, img.Width); if (provider.PixelType == PixelTypes.Rgba32) { Assert.IsType>(img); diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs index a35c73aef..437c295b9 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs @@ -118,7 +118,7 @@ namespace ImageSharp.Tests IEnumerable> expanded = pixelTypes.ExpandAllTypes(); - Assert.Equal(expanded.Count(), 4); + Assert.Equal(4, expanded.Count()); AssertContainsPixelType(PixelTypes.Alpha8, expanded); AssertContainsPixelType(PixelTypes.Bgr565, expanded);