Browse Source

invariant formatting for TestImageProvider.SourceFileOrDescription

af/merge-core
Anton Firszov 8 years ago
parent
commit
4cb2aa412e
  1. 3
      tests/ImageSharp.Tests/TestUtilities/ImageProviders/BlankProvider.cs
  2. 2
      tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs
  3. 2
      tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs
  4. 6
      tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs
  5. 4
      tests/ImageSharp.Tests/TestUtilities/TestUtils.cs

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

@ -19,13 +19,14 @@ namespace SixLabors.ImageSharp.Tests
this.Width = width;
this.Height = height;
}
public BlankProvider()
{
this.Width = 100;
this.Height = 100;
}
public override string SourceFileOrDescription => $"Blank{this.Width}x{this.Height}";
public override string SourceFileOrDescription => TestUtils.AsInvariantString($"Blank{this.Width}x{this.Height}");
protected int Height { get; private set; }

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

@ -47,7 +47,7 @@ namespace SixLabors.ImageSharp.Tests
}
public override string SourceFileOrDescription
=> $"Solid{this.Width}x{this.Height}_({this.r},{this.g},{this.b},{this.a})";
=> TestUtils.AsInvariantString($"Solid{this.Width}x{this.Height}_({this.r},{this.g},{this.b},{this.a})");
public override Image<TPixel> GetImage()
{

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

@ -30,7 +30,7 @@ namespace SixLabors.ImageSharp.Tests
{
}
public override string SourceFileOrDescription => $"TestPattern{this.Width}x{this.Height}";
public override string SourceFileOrDescription => TestUtils.AsInvariantString($"TestPattern{this.Width}x{this.Height}");
public override Image<TPixel> GetImage()
{

6
tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs

@ -95,8 +95,6 @@ namespace SixLabors.ImageSharp.Tests
return $"{this.GetTestOutputDir()}/{this.TestName}{pixName}{fn}{details}{extension}";
}
private static string Inv(FormattableString formattable) => System.FormattableString.Invariant(formattable);
/// <summary>
/// Gets the recommended file name for the output of the test
/// </summary>
@ -123,7 +121,7 @@ namespace SixLabors.ImageSharp.Tests
TypeInfo info = type.GetTypeInfo();
if (info.IsPrimitive || info.IsEnum || type == typeof(decimal))
{
detailsString = Inv($"{testOutputDetails}");
detailsString = TestUtils.AsInvariantString($"{testOutputDetails}");
}
else
{
@ -132,7 +130,7 @@ namespace SixLabors.ImageSharp.Tests
detailsString = string.Join(
"_",
properties.ToDictionary(x => x.Name, x => x.GetValue(testOutputDetails))
.Select(x => Inv($"{x.Key}-{x.Value}"))
.Select(x => TestUtils.AsInvariantString($"{x.Key}-{x.Value}"))
);
}
}

4
tests/ImageSharp.Tests/TestUtilities/TestUtils.cs

@ -101,7 +101,7 @@ namespace SixLabors.ImageSharp.Tests
public static string ToCsv<T>(this IEnumerable<T> items, string separator = ",")
{
return string.Join(separator, items.Select(o => string.Format(CultureInfo.InvariantCulture, "{0}", o)));
return String.Join(separator, items.Select(o => String.Format(CultureInfo.InvariantCulture, "{0}", o)));
}
public static Type GetClrType(this PixelTypes pixelType) => PixelTypes2ClrTypes[pixelType];
@ -227,5 +227,7 @@ namespace SixLabors.ImageSharp.Tests
image.DebugSave(provider, testOutputDetails);
}
}
public static string AsInvariantString(this FormattableString formattable) => System.FormattableString.Invariant(formattable);
}
}
Loading…
Cancel
Save