Browse Source

test clenup (xUnit analyzer warnings mostly)

pull/242/head
Anton Firszov 9 years ago
parent
commit
abd4c19bed
  1. 2
      tests/ImageSharp.Tests/Common/BufferTests.cs
  2. 2
      tests/ImageSharp.Tests/Common/ConstantsTests.cs
  3. 4
      tests/ImageSharp.Tests/Drawing/Text/TextGraphicsOptionsTests.cs
  4. 10
      tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs
  5. 18
      tests/ImageSharp.Tests/Formats/Jpg/YCbCrImageTests.cs
  6. 12
      tests/ImageSharp.Tests/IO/BigEndianBitConverter.ToTypeTests.cs
  7. 8
      tests/ImageSharp.Tests/IO/LittleEndianBitConverter.ToTypeTests.cs
  8. 6
      tests/ImageSharp.Tests/MetaData/ImagePropertyTests.cs
  9. 2
      tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifValueTests.cs
  10. 1
      tests/ImageSharp.Tests/Numerics/RectangleFTests.cs
  11. 51
      tests/ImageSharp.Tests/PixelFormats/Bgr24Tests.cs
  12. 46
      tests/ImageSharp.Tests/PixelFormats/Bgra32Tests.cs
  13. 8
      tests/ImageSharp.Tests/PixelFormats/PackedPixelTests.cs
  14. 3
      tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs
  15. 2
      tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs
  16. 4
      tests/ImageSharp.Tests/Processing/Transforms/ResizeProfilingBenchmarks.cs
  17. 14
      tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs
  18. 2
      tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs

2
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);
}
}

2
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);
}
}
}

4
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);
}
}

10
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

18
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}");
}
}
}

12
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));
}
/// <summary>

8
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));
}
/// <summary>

6
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);
}
/// <summary>
@ -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);

2
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);
}

1
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)

51
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<byte, byte, byte> 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));
}
}
}

46
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<byte, byte, byte, byte> 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));
}
}
}

8
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];

3
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;

2
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]);
}
}
}

4
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,

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

@ -103,8 +103,8 @@ namespace ImageSharp.Tests
where TPixel : struct, IPixel<TPixel>
{
Image<TPixel> 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<TPixel>
{
Image<TPixel> img = provider.GetImage();
Assert.Equal(img.Width, 3);
Assert.Equal(3, img.Width);
if (provider.PixelType == PixelTypes.Rgba32)
{
Assert.IsType<Image<Rgba32>>(img);

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

@ -118,7 +118,7 @@ namespace ImageSharp.Tests
IEnumerable<KeyValuePair<PixelTypes, Type>> expanded = pixelTypes.ExpandAllTypes();
Assert.Equal(expanded.Count(), 4);
Assert.Equal(4, expanded.Count());
AssertContainsPixelType<Alpha8>(PixelTypes.Alpha8, expanded);
AssertContainsPixelType<Bgr565>(PixelTypes.Bgr565, expanded);

Loading…
Cancel
Save