diff --git a/tests/ImageSharp.Tests/Drawing/BeziersTests.cs b/tests/ImageSharp.Tests/Drawing/BeziersTests.cs index 0b0a474834..5ffd9f5f14 100644 --- a/tests/ImageSharp.Tests/Drawing/BeziersTests.cs +++ b/tests/ImageSharp.Tests/Drawing/BeziersTests.cs @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByBezierLine() { - string path = this.CreateOutputDirectory("Drawing", "BezierLine"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "BezierLine"); using (Image image = new Image(500, 500)) { image.Mutate(x => x.BackgroundColor(Rgba32.Blue) @@ -53,7 +53,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedBezierLineWithOpacity() { - string path = this.CreateOutputDirectory("Drawing", "BezierLine"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "BezierLine"); Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); diff --git a/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs b/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs index 10d31a0d18..429acafb95 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs @@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByPath() { - string path = this.CreateOutputDirectory("Drawing", "Path"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "Path"); using (Image image = new Image(500, 500)) { LinearLineSegment linerSegemnt = new LinearLineSegment( @@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedPathWithOpacity() { - string path = this.CreateOutputDirectory("Drawing", "Path"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "Path"); Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); @@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing public void PathExtendingOffEdgeOfImageShouldNotBeCropped() { - string path = this.CreateOutputDirectory("Drawing", "Path"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "Path"); using (var image = new Image(256, 256)) { image.Mutate(x => x.Fill(Rgba32.Black)); diff --git a/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs b/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs index 10988e9d13..d37058f5d1 100644 --- a/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing { private void Test(string name, Rgba32 background, IBrush brush, Rgba32[,] expectedPattern) { - string path = this.CreateOutputDirectory("Fill", "PatternBrush"); + string path = TestEnvironment.CreateOutputDirectory("Fill", "PatternBrush"); using (Image image = new Image(20, 20)) { image.Mutate(x => x diff --git a/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs b/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs index 9d64d63191..6eb139baca 100644 --- a/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeFloodFilledWithColorOnDefaultBackground() { - string path = this.CreateOutputDirectory("Fill", "SolidBrush"); + string path = TestEnvironment.CreateOutputDirectory("Fill", "SolidBrush"); using (Image image = new Image(500, 500)) { image.Mutate(x => x @@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeFloodFilledWithColor() { - string path = this.CreateOutputDirectory("Fill", "SolidBrush"); + string path = TestEnvironment.CreateOutputDirectory("Fill", "SolidBrush"); using (Image image = new Image(500, 500)) { image.Mutate(x => x @@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeFloodFilledWithColorOpacity() { - string path = this.CreateOutputDirectory("Fill", "SolidBrush"); + string path = TestEnvironment.CreateOutputDirectory("Fill", "SolidBrush"); using (Image image = new Image(500, 500)) { Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); diff --git a/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs index 3fe67a5aa1..6c0670a85e 100644 --- a/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs @@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByPolygonOutline() { - string path = this.CreateOutputDirectory("Drawing", "LineComplexPolygon"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "LineComplexPolygon"); Polygon simplePath = new Polygon(new LinearLineSegment( new Vector2(10, 10), @@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByPolygonOutlineNoOverlapping() { - string path = this.CreateOutputDirectory("Drawing", "LineComplexPolygon"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "LineComplexPolygon"); Polygon simplePath = new Polygon(new LinearLineSegment( new Vector2(10, 10), new Vector2(200, 150), @@ -113,7 +113,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByPolygonOutlineOverlapping() { - string path = this.CreateOutputDirectory("Drawing", "LineComplexPolygon"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "LineComplexPolygon"); Polygon simplePath = new Polygon(new LinearLineSegment( new Vector2(10, 10), new Vector2(200, 150), @@ -156,7 +156,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByPolygonOutlineDashed() { - string path = this.CreateOutputDirectory("Drawing", "LineComplexPolygon"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "LineComplexPolygon"); Polygon simplePath = new Polygon(new LinearLineSegment( new Vector2(10, 10), new Vector2(200, 150), @@ -180,7 +180,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedPolygonOutlineWithOpacity() { - string path = this.CreateOutputDirectory("Drawing", "LineComplexPolygon"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "LineComplexPolygon"); Polygon simplePath = new Polygon(new LinearLineSegment( new Vector2(10, 10), new Vector2(200, 150), diff --git a/tests/ImageSharp.Tests/Drawing/LineTests.cs b/tests/ImageSharp.Tests/Drawing/LineTests.cs index c2d60d4adb..d8c5c41d8b 100644 --- a/tests/ImageSharp.Tests/Drawing/LineTests.cs +++ b/tests/ImageSharp.Tests/Drawing/LineTests.cs @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByPath() { - string path = this.CreateOutputDirectory("Drawing", "Lines"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines"); using (Image image = new Image(500, 500)) { image.Mutate(x => x @@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByPath_NoAntialias() { - string path = this.CreateOutputDirectory("Drawing", "Lines"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines"); using (Image image = new Image(500, 500)) { image.Mutate(x => x @@ -70,7 +70,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByPathDashed() { - string path = this.CreateOutputDirectory("Drawing", "Lines"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines"); using (Image image = new Image(500, 500)) { image.Mutate(x => x @@ -88,7 +88,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByPathDotted() { - string path = this.CreateOutputDirectory("Drawing", "Lines"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines"); using (Image image = new Image(500, 500)) { image.Mutate(x => x @@ -106,7 +106,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByPathDashDot() { - string path = this.CreateOutputDirectory("Drawing", "Lines"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines"); using (Image image = new Image(500, 500)) { image.Mutate(x => x @@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByPathDashDotDot() { - string path = this.CreateOutputDirectory("Drawing", "Lines"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines"); Image image = new Image(500, 500); image.Mutate(x => x @@ -140,7 +140,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedPathWithOpacity() { - string path = this.CreateOutputDirectory("Drawing", "Lines"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines"); Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); @@ -171,7 +171,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByPathOutline() { - string path = this.CreateOutputDirectory("Drawing", "Lines"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines"); Image image = new Image(500, 500); diff --git a/tests/ImageSharp.Tests/Drawing/PolygonTests.cs b/tests/ImageSharp.Tests/Drawing/PolygonTests.cs index 996387d14c..a43f14eb71 100644 --- a/tests/ImageSharp.Tests/Drawing/PolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/PolygonTests.cs @@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByPolygonOutline() { - string path = this.CreateOutputDirectory("Drawing", "Polygons"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "Polygons"); using (Image image = new Image(500, 500)) { @@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedPolygonOutlineWithOpacity() { - string path = this.CreateOutputDirectory("Drawing", "Polygons"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "Polygons"); SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 150), @@ -83,7 +83,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByRectangleOutline() { - string path = this.CreateOutputDirectory("Drawing", "Polygons"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "Polygons"); using (Image image = new Image(500, 500)) { diff --git a/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs b/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs index d2bbdbb052..52668cc56c 100644 --- a/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs +++ b/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs @@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Tests [Fact] public void ImageShouldRecolorYellowToHotPink() { - string path = this.CreateOutputDirectory("Drawing", "RecolorImage"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "RecolorImage"); RecolorBrush brush = new RecolorBrush(Rgba32.Yellow, Rgba32.HotPink, 0.2f); @@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp.Tests [Fact] public void ImageShouldRecolorYellowToHotPinkInARectangle() { - string path = this.CreateOutputDirectory("Drawing", "RecolorImage"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "RecolorImage"); RecolorBrush brush = new RecolorBrush(Rgba32.Yellow, Rgba32.HotPink, 0.2f); diff --git a/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs b/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs index 0ddd99712e..07e75acf43 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs @@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByFilledPolygon() { - string path = this.CreateOutputDirectory("Drawing", "FilledBezier"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledBezier"); SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] { new Vector2(10, 400), new Vector2(30, 10), @@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByFilledPolygonOpacity() { - string path = this.CreateOutputDirectory("Drawing", "FilledBezier"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledBezier"); SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] { new Vector2(10, 400), new Vector2(30, 10), diff --git a/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs index 8bad1a6b06..e1849b0d01 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs @@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByPolygonOutline() { - string path = this.CreateOutputDirectory("Drawing", "ComplexPolygon"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "ComplexPolygon"); Polygon simplePath = new Polygon(new LinearLineSegment( new Vector2(10, 10), new Vector2(200, 150), @@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedPolygonOutlineWithOverlap() { - string path = this.CreateOutputDirectory("Drawing", "ComplexPolygon"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "ComplexPolygon"); Polygon simplePath = new Polygon(new LinearLineSegment( new Vector2(10, 10), new Vector2(200, 150), @@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedPolygonOutlineWithOpacity() { - string path = this.CreateOutputDirectory("Drawing", "ComplexPolygon"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "ComplexPolygon"); Polygon simplePath = new Polygon(new LinearLineSegment( new Vector2(10, 10), new Vector2(200, 150), diff --git a/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs index 10625dedbf..c210b66ed7 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs @@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByFilledPolygon() { - string path = this.CreateOutputDirectory("Drawing", "FilledPolygons"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons"); SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 150), @@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByFilledPolygonWithPattern() { - string path = this.CreateOutputDirectory("Drawing", "FilledPolygons"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons"); SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 150), @@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByFilledPolygonNoAntialias() { - string path = this.CreateOutputDirectory("Drawing", "FilledPolygons"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons"); SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 150), @@ -95,7 +95,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByFilledPolygonImage() { - string path = this.CreateOutputDirectory("Drawing", "FilledPolygons"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons"); SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 150), @@ -117,7 +117,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByFilledPolygonOpacity() { - string path = this.CreateOutputDirectory("Drawing", "FilledPolygons"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons"); SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] { new Vector2(10, 10), new Vector2(200, 150), @@ -145,7 +145,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByFilledRectangle() { - string path = this.CreateOutputDirectory("Drawing", "FilledPolygons"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons"); using (Image image = new Image(500, 500)) { @@ -172,7 +172,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByFilledTriangle() { - string path = this.CreateOutputDirectory("Drawing", "FilledPolygons"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons"); using (Image image = new Image(100, 100)) { @@ -193,7 +193,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByFilledSeptagon() { - string path = this.CreateOutputDirectory("Drawing", "FilledPolygons"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons"); Configuration config = Configuration.CreateDefaultInstance(); config.ParallelOptions.MaxDegreeOfParallelism = 1; @@ -209,7 +209,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedByFilledEllipse() { - string path = this.CreateOutputDirectory("Drawing", "FilledPolygons"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons"); Configuration config = Configuration.CreateDefaultInstance(); config.ParallelOptions.MaxDegreeOfParallelism = 1; @@ -226,7 +226,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeOverlayedBySquareWithCornerClipped() { - string path = this.CreateOutputDirectory("Drawing", "FilledPolygons"); + string path = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons"); Configuration config = Configuration.CreateDefaultInstance(); config.ParallelOptions.MaxDegreeOfParallelism = 1; diff --git a/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs b/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs index 07041956d6..079510c33a 100644 --- a/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs +++ b/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs @@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text { img.Mutate(x => x.Fill(Rgba32.DarkBlue) .DrawText("AB\nAB", new Font(this.Font, 50), Rgba32.Red, new Vector2(0, 0))); - img.Save($"{this.CreateOutputDirectory("Drawing", "Text")}/AB.png"); + img.Save($"{TestEnvironment.CreateOutputDirectory("Drawing", "Text")}/AB.png"); } } } diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs index ffadb8a9e6..d96d3def5e 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs @@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Tests [MemberData(nameof(BitsPerPixel))] public void BitmapCanEncodeDifferentBitRates(BmpBitsPerPixel bitsPerPixel) { - string path = this.CreateOutputDirectory("Bmp"); + string path = TestEnvironment.CreateOutputDirectory("Bmp"); foreach (TestFile file in Files) { diff --git a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs index d275decfb7..473bc2b523 100644 --- a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs +++ b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs @@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.Tests [Fact] public void ImageCanEncodeToString() { - string path = this.CreateOutputDirectory("ToString"); + string path = TestEnvironment.CreateOutputDirectory("ToString"); foreach (TestFile file in Files) { @@ -41,7 +41,7 @@ namespace SixLabors.ImageSharp.Tests [Fact] public void DecodeThenEncodeImageFromStreamShouldSucceed() { - string path = this.CreateOutputDirectory("Encode"); + string path = TestEnvironment.CreateOutputDirectory("Encode"); foreach (TestFile file in Files) { @@ -55,7 +55,7 @@ namespace SixLabors.ImageSharp.Tests [Fact] public void QuantizeImageShouldPreserveMaximumColorPrecision() { - string path = this.CreateOutputDirectory("Quantize"); + string path = TestEnvironment.CreateOutputDirectory("Quantize"); foreach (TestFile file in Files) { @@ -95,7 +95,7 @@ namespace SixLabors.ImageSharp.Tests [Fact] public void ImageCanConvertFormat() { - string path = this.CreateOutputDirectory("Format"); + string path = TestEnvironment.CreateOutputDirectory("Format"); foreach (TestFile file in Files) { @@ -127,7 +127,7 @@ namespace SixLabors.ImageSharp.Tests [Fact] public void ImageShouldPreservePixelByteOrderWhenSerialized() { - string path = this.CreateOutputDirectory("Serialized"); + string path = TestEnvironment.CreateOutputDirectory("Serialized"); foreach (TestFile file in Files) { diff --git a/tests/ImageSharp.Tests/Formats/Jpg/LibJpegTools.cs b/tests/ImageSharp.Tests/Formats/Jpg/LibJpegTools.cs index f9cb316814..851e600633 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/LibJpegTools.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/LibJpegTools.cs @@ -453,5 +453,10 @@ namespace SixLabors.ImageSharp.Tests double result = (double)totalDiff; return result / (count * Block8x8.Size); } + + public static void RunDumpJpegCoeffsTool(string sourceFile, string destFile) + { + throw new NotImplementedException(); + } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs index 90c6eeb587..dfa1d91046 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/SpectralJpegTests.cs @@ -5,9 +5,11 @@ namespace SixLabors.ImageSharp.Tests using System.Collections.Generic; using System.IO; using System.Linq; + using System.Runtime.CompilerServices; using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats.Jpeg; + using SixLabors.ImageSharp.Formats.Jpeg.Common; using SixLabors.ImageSharp.Formats.Jpeg.GolangPort; using SixLabors.ImageSharp.Formats.Jpeg.PdfJsPort; using SixLabors.ImageSharp.PixelFormats; @@ -42,6 +44,13 @@ namespace SixLabors.ImageSharp.Tests public static readonly string[] AllTestJpegs = BaselineTestJpegs.Concat(ProgressiveTestJpegs).ToArray(); + [Fact] + public void RunDumpJpegCoeffsTool() + { + string inputFile = TestFile.GetInputFileFullPath(TestImages.Jpeg.Progressive.Progress); + + } + [Theory] [WithFileCollection(nameof(BaselineTestJpegs), PixelTypes.Rgba32)] public void BuildLibJpegSpectralResult(TestImageProvider provider) @@ -59,6 +68,40 @@ namespace SixLabors.ImageSharp.Tests } } + [Theory] + //[WithFileCollection(nameof(BaselineTestJpegs), PixelTypes.Rgba32)] + [WithFile(TestImages.Jpeg.Progressive.Progress, PixelTypes.Rgba32)] + public void HelloSerializedSpectralData(TestImageProvider provider) + where TPixel : struct, IPixel + { + byte[] sourceBytes = TestFile.Create(provider.SourceFileOrDescription).Bytes; + + using (var ms = new MemoryStream(sourceBytes)) + { + //LibJpegTools.SpectralData data = LibJpegTools.SpectralData.Load(ms); + OldJpegDecoderCore dec = new OldJpegDecoderCore(Configuration.Default, new JpegDecoder()); + dec.ParseStream(new MemoryStream(sourceBytes)); + + LibJpegTools.SpectralData data = LibJpegTools.SpectralData.LoadFromImageSharpDecoder(dec); + Assert.True(data.ComponentCount > 0); + this.Output.WriteLine($"ComponentCount: {data.ComponentCount}"); + + string comp0FileName = TestFile.GetInputFileFullPath(provider.SourceFileOrDescription + ".comp0"); + if (!File.Exists(comp0FileName)) + { + this.Output.WriteLine("Missing file: " + comp0FileName); + } + + byte[] stuff = File.ReadAllBytes(comp0FileName); + + ref Block8x8 actual = ref Unsafe.As(ref stuff[0]); + ref Block8x8 expected = ref data.Components[0].Blocks[0]; + + Assert.Equal(actual, expected); + //this.SaveSpectralImage(provider, data); + } + } + [Theory] [WithFileCollection(nameof(AllTestJpegs), PixelTypes.Rgba32)] public void PdfJsDecoder_ParseStream_SaveSpectralResult(TestImageProvider provider) diff --git a/tests/ImageSharp.Tests/Image/ImageTests.cs b/tests/ImageSharp.Tests/Image/ImageTests.cs index 323eaf65c0..fa19557dff 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.cs @@ -64,7 +64,7 @@ namespace SixLabors.ImageSharp.Tests [Fact] public void Save_DetecedEncoding() { - string dir = this.CreateOutputDirectory(nameof(ImageTests)); + string dir = TestEnvironment.CreateOutputDirectory(nameof(ImageTests)); string file = System.IO.Path.Combine(dir, "Save_DetecedEncoding.png"); using (Image image = new Image(10, 10)) @@ -81,7 +81,7 @@ namespace SixLabors.ImageSharp.Tests [Fact] public void Save_WhenExtensionIsUnknown_Throws() { - string dir = this.CreateOutputDirectory(nameof(ImageTests)); + string dir = TestEnvironment.CreateOutputDirectory(nameof(ImageTests)); string file = System.IO.Path.Combine(dir, "Save_UnknownExtensionsEncoding_Throws.tmp"); NotSupportedException ex = Assert.Throws( @@ -97,7 +97,7 @@ namespace SixLabors.ImageSharp.Tests [Fact] public void Save_SetEncoding() { - string dir = this.CreateOutputDirectory(nameof(ImageTests)); + string dir = TestEnvironment.CreateOutputDirectory(nameof(ImageTests)); string file = System.IO.Path.Combine(dir, "Save_SetEncoding.dat"); using (Image image = new Image(10, 10)) diff --git a/tests/ImageSharp.Tests/TestBase.cs b/tests/ImageSharp.Tests/TestBase.cs index f83c428fc2..ffacd749ca 100644 --- a/tests/ImageSharp.Tests/TestBase.cs +++ b/tests/ImageSharp.Tests/TestBase.cs @@ -12,29 +12,5 @@ namespace SixLabors.ImageSharp.Tests /// public abstract class TestBase { - /// - /// Creates the image output directory. - /// - /// The path. - /// The path parts. - /// - /// The . - /// - protected string CreateOutputDirectory(string path, params string[] pathParts) - { - path = Path.Combine(TestEnvironment.ActualOutputDirectoryFullPath, path); - - if (pathParts != null && pathParts.Length > 0) - { - path = Path.Combine(path, Path.Combine(pathParts)); - } - - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } - - return path; - } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs b/tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs index 88c69a979b..efb6ecc598 100644 --- a/tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs +++ b/tests/ImageSharp.Tests/TestUtilities/ImagingTestCaseUtility.cs @@ -194,7 +194,7 @@ namespace SixLabors.ImageSharp.Tests internal string GetTestOutputDir() { string testGroupName = Path.GetFileNameWithoutExtension(this.TestGroupName); - return this.CreateOutputDirectory(testGroupName); + return TestEnvironment.CreateOutputDirectory(testGroupName); } public static void ModifyPixel(ImageBase img, int x, int y, byte perChannelChange) diff --git a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs index 1bd0f77d27..dd8a08fcd4 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestEnvironment.cs @@ -27,13 +27,15 @@ namespace SixLabors.ImageSharp.Tests private const string ReferenceOutputDirectoryRelativePath = @"tests\Images\External\ReferenceOutput"; + private const string ToolsDirectoryRelativePath = @"tests\Images\External\tools"; + private static Lazy solutionDirectoryFullPath = new Lazy(GetSolutionDirectoryFullPathImpl); private static Lazy runsOnCi = new Lazy( () => { bool isCi; - return bool.TryParse(Environment.GetEnvironmentVariable("CI"), out isCi) && isCi; + return Boolean.TryParse(Environment.GetEnvironmentVariable("CI"), out isCi) && isCi; }); private static Lazy configuration = new Lazy(CreateDefaultConfiguration); @@ -120,25 +122,26 @@ namespace SixLabors.ImageSharp.Tests return directory.FullName; } + private static string GetFullPath(string relativePath) => + Path.Combine(SolutionDirectoryFullPath, relativePath) + .Replace('\\', Path.DirectorySeparatorChar); + /// /// Gets the correct full path to the Input Images directory. /// - internal static string InputImagesDirectoryFullPath => - Path.Combine(SolutionDirectoryFullPath, InputImagesRelativePath).Replace('\\', Path.DirectorySeparatorChar); - + internal static string InputImagesDirectoryFullPath => GetFullPath(InputImagesRelativePath); + /// /// Gets the correct full path to the Actual Output directory. (To be written to by the test cases.) /// - internal static string ActualOutputDirectoryFullPath => Path.Combine( - SolutionDirectoryFullPath, - ActualOutputDirectoryRelativePath).Replace('\\', Path.DirectorySeparatorChar); + internal static string ActualOutputDirectoryFullPath => GetFullPath(ActualOutputDirectoryRelativePath); /// /// Gets the correct full path to the Expected Output directory. (To compare the test results to.) /// - internal static string ReferenceOutputDirectoryFullPath => Path.Combine( - SolutionDirectoryFullPath, - ReferenceOutputDirectoryRelativePath).Replace('\\', Path.DirectorySeparatorChar); + internal static string ReferenceOutputDirectoryFullPath => GetFullPath(ReferenceOutputDirectoryRelativePath); + + internal static string ToolsDirectoryFullPath => GetFullPath(ToolsDirectoryRelativePath); internal static string GetReferenceOutputFileName(string actualOutputFileName) => actualOutputFileName.Replace("ActualOutput", @"External\ReferenceOutput").Replace('\\', Path.DirectorySeparatorChar); @@ -163,7 +166,33 @@ namespace SixLabors.ImageSharp.Tests return format; } - internal static bool IsLinux => - System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Linux); + internal static bool IsLinux => RuntimeInformation.IsOSPlatform(OSPlatform.Linux); + + internal static bool IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + + /// + /// Creates the image output directory. + /// + /// The path. + /// The path parts. + /// + /// The . + /// + internal static string CreateOutputDirectory(string path, params string[] pathParts) + { + path = Path.Combine(TestEnvironment.ActualOutputDirectoryFullPath, path); + + if (pathParts != null && pathParts.Length > 0) + { + path = Path.Combine(path, Path.Combine(pathParts)); + } + + if (!Directory.Exists(path)) + { + Directory.CreateDirectory(path); + } + + return path; + } } } \ No newline at end of file