From d72ed0ac0164293249f701126b35d750098eed61 Mon Sep 17 00:00:00 2001 From: dirk Date: Fri, 21 Oct 2016 20:55:44 +0200 Subject: [PATCH] Refactored creating the output directory. Former-commit-id: f23cc3264514e4c882d0a2ed41ffc23f9abb54ef Former-commit-id: b9e32392f090e1fd3f0c534bad3939360d0dcecd Former-commit-id: 6276382a7659cc1f3fed381c2cedcee611947da5 --- .../ImageProcessorCore.Tests/FileTestBase.cs | 13 +++++ .../Formats/Bmp/BitmapTests.cs | 6 +-- .../Formats/GeneralFormatTests.cs | 36 +++---------- .../Formats/Png/PngTests.cs | 6 +-- .../Processors/Filters/AlphaTest.cs | 12 +---- .../Processors/Filters/BackgroundColorTest.cs | 6 +-- .../Processors/Filters/BinaryThreshold.cs | 6 +-- .../Processors/Filters/BlackWhiteTest.cs | 6 +-- .../Processors/Filters/BlendTest.cs | 8 +-- .../Processors/Filters/BoxBlurTest.cs | 6 +-- .../Processors/Filters/BrightnessTest.cs | 6 +-- .../Processors/Filters/ColorBlindnessTest.cs | 6 +-- .../Processors/Filters/ContrastTest.cs | 6 +-- .../Processors/Filters/GlowTest.cs | 24 ++------- .../Processors/Filters/GrayscaleTest.cs | 6 +-- .../Processors/Filters/HueTest.cs | 6 +-- .../Processors/Filters/InvertTest.cs | 13 +---- .../Processors/Filters/KodachromeTest.cs | 6 +-- .../Processors/Filters/LomographTest.cs | 13 ++--- .../Processors/Filters/PolaroidTest.cs | 6 +-- .../Processors/Filters/SaturationTest.cs | 6 +-- .../Processors/Filters/SepiaTest.cs | 6 +-- .../Processors/Filters/VignetteTest.cs | 24 ++------- .../Processors/Samplers/AutoOrientTests.cs | 6 +-- .../Processors/Samplers/CropTest.cs | 6 +-- .../Processors/Samplers/DetectEdgesTest.cs | 12 +---- .../Processors/Samplers/EntropyCropTest.cs | 6 +-- .../Processors/Samplers/FlipTests.cs | 6 +-- .../Processors/Samplers/GuassianBlurTest.cs | 6 +-- .../Samplers/GuassianSharpenTest.cs | 6 +-- .../Processors/Samplers/OilPaintTest.cs | 12 +---- .../Processors/Samplers/PadTest.cs | 6 +-- .../Processors/Samplers/PixelateTest.cs | 12 +---- .../Processors/Samplers/ResizeTests.cs | 52 ++++--------------- .../Processors/Samplers/RotateFlipTest.cs | 6 +-- .../Processors/Samplers/RotateTest.cs | 12 +---- .../Processors/Samplers/SkewTest.cs | 6 +-- 37 files changed, 78 insertions(+), 309 deletions(-) diff --git a/tests/ImageProcessorCore.Tests/FileTestBase.cs b/tests/ImageProcessorCore.Tests/FileTestBase.cs index 2fd6b87088..2da17f37e5 100644 --- a/tests/ImageProcessorCore.Tests/FileTestBase.cs +++ b/tests/ImageProcessorCore.Tests/FileTestBase.cs @@ -5,6 +5,7 @@ namespace ImageProcessorCore.Tests { + using System.IO; using System.Collections.Generic; /// @@ -34,5 +35,17 @@ namespace ImageProcessorCore.Tests new TestFile(TestImages.Gif.Rings), //new TestFile(TestImages.Gif.Giphy) // Perf: Enable for local testing only }; + + protected string CreateOutputDirectory(string path) + { + path = "TestOutput/" + path; + + if (!Directory.Exists(path)) + { + Directory.CreateDirectory(path); + } + + return path; + } } } \ No newline at end of file diff --git a/tests/ImageProcessorCore.Tests/Formats/Bmp/BitmapTests.cs b/tests/ImageProcessorCore.Tests/Formats/Bmp/BitmapTests.cs index 92c9956691..aac69cf158 100644 --- a/tests/ImageProcessorCore.Tests/Formats/Bmp/BitmapTests.cs +++ b/tests/ImageProcessorCore.Tests/Formats/Bmp/BitmapTests.cs @@ -24,11 +24,7 @@ namespace ImageProcessorCore.Tests [MemberData("BitsPerPixel")] public void BitmapCanEncodeDifferentBitRates(BmpBitsPerPixel bitsPerPixel) { - const string path = "TestOutput/Bmp"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Bmp"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Formats/GeneralFormatTests.cs b/tests/ImageProcessorCore.Tests/Formats/GeneralFormatTests.cs index 5989b923d1..b52abe3fc1 100644 --- a/tests/ImageProcessorCore.Tests/Formats/GeneralFormatTests.cs +++ b/tests/ImageProcessorCore.Tests/Formats/GeneralFormatTests.cs @@ -15,11 +15,7 @@ namespace ImageProcessorCore.Tests [Fact] public void ResolutionShouldChange() { - const string path = "TestOutput/Resolution"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Resolution"); foreach (TestFile file in Files) { @@ -37,11 +33,7 @@ namespace ImageProcessorCore.Tests [Fact] public void ImageCanEncodeToString() { - const string path = "TestOutput/ToString"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("ToString"); foreach (TestFile file in Files) { @@ -55,11 +47,7 @@ namespace ImageProcessorCore.Tests [Fact] public void DecodeThenEncodeImageFromStreamShouldSucceed() { - const string path = "TestOutput/Encode"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Encode"); foreach (TestFile file in Files) { @@ -75,11 +63,7 @@ namespace ImageProcessorCore.Tests [Fact] public void QuantizeImageShouldPreserveMaximumColorPrecision() { - const string path = "TestOutput/Quantize"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Quantize"); foreach (TestFile file in Files) { @@ -115,11 +99,7 @@ namespace ImageProcessorCore.Tests [Fact] public void ImageCanConvertFormat() { - const string path = "TestOutput/Format"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Format"); foreach (TestFile file in Files) { @@ -150,11 +130,7 @@ namespace ImageProcessorCore.Tests [Fact] public void ImageShouldPreservePixelByteOrderWhenSerialized() { - const string path = "TestOutput/Serialized"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Serialized"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Formats/Png/PngTests.cs b/tests/ImageProcessorCore.Tests/Formats/Png/PngTests.cs index 3d4baf36d8..598ab4ae76 100644 --- a/tests/ImageProcessorCore.Tests/Formats/Png/PngTests.cs +++ b/tests/ImageProcessorCore.Tests/Formats/Png/PngTests.cs @@ -16,11 +16,7 @@ namespace ImageProcessorCore.Tests [Fact] public void ImageCanSaveIndexedPng() { - const string path = "TestOutput/Png"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Png"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Filters/AlphaTest.cs b/tests/ImageProcessorCore.Tests/Processors/Filters/AlphaTest.cs index 9059b0a182..664e948714 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Filters/AlphaTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Filters/AlphaTest.cs @@ -22,11 +22,7 @@ namespace ImageProcessorCore.Tests [MemberData("AlphaValues")] public void ImageShouldApplyAlphaFilter(int value) { - const string path = "TestOutput/Alpha"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Alpha"); foreach (TestFile file in Files) { @@ -45,11 +41,7 @@ namespace ImageProcessorCore.Tests [MemberData("AlphaValues")] public void ImageShouldApplyAlphaFilterInBox(int value) { - const string path = "TestOutput/Alpha"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Alpha"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Filters/BackgroundColorTest.cs b/tests/ImageProcessorCore.Tests/Processors/Filters/BackgroundColorTest.cs index 7b0f8ac9cd..6824fd8cda 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Filters/BackgroundColorTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Filters/BackgroundColorTest.cs @@ -14,11 +14,7 @@ namespace ImageProcessorCore.Tests [Fact] public void ImageShouldApplyBackgroundColorFilter() { - const string path = "TestOutput/BackgroundColor"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("BackgroundColor"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Filters/BinaryThreshold.cs b/tests/ImageProcessorCore.Tests/Processors/Filters/BinaryThreshold.cs index 039d20a49e..74eddb18a1 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Filters/BinaryThreshold.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Filters/BinaryThreshold.cs @@ -22,11 +22,7 @@ namespace ImageProcessorCore.Tests [MemberData("BinaryThresholdValues")] public void ImageShouldApplyBinaryThresholdFilter(float value) { - const string path = "TestOutput/BinaryThreshold"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("BinaryThreshold"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Filters/BlackWhiteTest.cs b/tests/ImageProcessorCore.Tests/Processors/Filters/BlackWhiteTest.cs index e6891ede47..9b475edc0b 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Filters/BlackWhiteTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Filters/BlackWhiteTest.cs @@ -14,11 +14,7 @@ namespace ImageProcessorCore.Tests [Fact] public void ImageShouldApplyBlackWhiteFilter() { - const string path = "TestOutput/BlackWhite"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("BlackWhite"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Filters/BlendTest.cs b/tests/ImageProcessorCore.Tests/Processors/Filters/BlendTest.cs index 495a49f39b..ada41339d8 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Filters/BlendTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Filters/BlendTest.cs @@ -14,14 +14,10 @@ namespace ImageProcessorCore.Tests [Fact] public void ImageShouldApplyBlendFilter() { - const string path = "TestOutput/Blend"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Blend"); Image blend; - using (FileStream stream = File.OpenRead("TestImages/Formats/Bmp/Car.bmp")) + using (FileStream stream = File.OpenRead(TestImages.Bmp.Car)) { blend = new Image(stream); } diff --git a/tests/ImageProcessorCore.Tests/Processors/Filters/BoxBlurTest.cs b/tests/ImageProcessorCore.Tests/Processors/Filters/BoxBlurTest.cs index cf31d8e9b6..e803fcb5dd 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Filters/BoxBlurTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Filters/BoxBlurTest.cs @@ -22,11 +22,7 @@ namespace ImageProcessorCore.Tests [MemberData("BoxBlurValues")] public void ImageShouldApplyBoxBlurFilter(int value) { - const string path = "TestOutput/BoxBlur"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("BoxBlur"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Filters/BrightnessTest.cs b/tests/ImageProcessorCore.Tests/Processors/Filters/BrightnessTest.cs index 6160143ec7..e2fb370b00 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Filters/BrightnessTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Filters/BrightnessTest.cs @@ -22,11 +22,7 @@ namespace ImageProcessorCore.Tests [MemberData("BrightnessValues")] public void ImageShouldApplyBrightnessFilter(int value) { - const string path = "TestOutput/Brightness"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Brightness"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Filters/ColorBlindnessTest.cs b/tests/ImageProcessorCore.Tests/Processors/Filters/ColorBlindnessTest.cs index b75e26b002..83ced1eba4 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Filters/ColorBlindnessTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Filters/ColorBlindnessTest.cs @@ -28,11 +28,7 @@ namespace ImageProcessorCore.Tests [MemberData("ColorBlindnessFilters")] public void ImageShouldApplyColorBlindnessFilter(ColorBlindness colorBlindness) { - const string path = "TestOutput/ColorBlindness"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("ColorBlindness"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Filters/ContrastTest.cs b/tests/ImageProcessorCore.Tests/Processors/Filters/ContrastTest.cs index dc9d452dbc..a18f5993e7 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Filters/ContrastTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Filters/ContrastTest.cs @@ -22,11 +22,7 @@ namespace ImageProcessorCore.Tests [MemberData("ContrastValues")] public void ImageShouldApplyContrastFilter(int value) { - const string path = "TestOutput/Contrast"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Contrast"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Filters/GlowTest.cs b/tests/ImageProcessorCore.Tests/Processors/Filters/GlowTest.cs index 551b777ac7..19ceaa04bf 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Filters/GlowTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Filters/GlowTest.cs @@ -14,11 +14,7 @@ namespace ImageProcessorCore.Tests [Fact] public void ImageShouldApplyGlowFilter() { - const string path = "TestOutput/Glow"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Glow"); foreach (TestFile file in Files) { @@ -35,11 +31,7 @@ namespace ImageProcessorCore.Tests [Fact] public void ImageShouldApplyGlowFilterColor() { - const string path = "TestOutput/Glow"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Glow"); foreach (TestFile file in Files) { @@ -57,11 +49,7 @@ namespace ImageProcessorCore.Tests [Fact] public void ImageShouldApplyGlowFilterRadius() { - const string path = "TestOutput/Glow"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Glow"); foreach (TestFile file in Files) { @@ -79,11 +67,7 @@ namespace ImageProcessorCore.Tests [Fact] public void ImageShouldApplyGlowFilterInBox() { - const string path = "TestOutput/Glow"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Glow"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Filters/GrayscaleTest.cs b/tests/ImageProcessorCore.Tests/Processors/Filters/GrayscaleTest.cs index e74797fff0..edbe8000f8 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Filters/GrayscaleTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Filters/GrayscaleTest.cs @@ -23,11 +23,7 @@ namespace ImageProcessorCore.Tests [MemberData("GrayscaleValues")] public void ImageShouldApplyGrayscaleFilter(GrayscaleMode value) { - const string path = "TestOutput/Grayscale"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Grayscale"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Filters/HueTest.cs b/tests/ImageProcessorCore.Tests/Processors/Filters/HueTest.cs index 08d7f2d224..7c0bde66ea 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Filters/HueTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Filters/HueTest.cs @@ -22,11 +22,7 @@ namespace ImageProcessorCore.Tests [MemberData("HueValues")] public void ImageShouldApplyHueFilter(int value) { - const string path = "TestOutput/Hue"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Hue"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Filters/InvertTest.cs b/tests/ImageProcessorCore.Tests/Processors/Filters/InvertTest.cs index 4c516d7f18..66636e41c1 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Filters/InvertTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Filters/InvertTest.cs @@ -14,12 +14,7 @@ namespace ImageProcessorCore.Tests [Fact] public void ImageShouldApplyInvertFilter() { - const string path = "TestOutput/Invert"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } - + string path = CreateOutputDirectory("Invert"); foreach (TestFile file in Files) { Image image = file.CreateImage(); @@ -35,11 +30,7 @@ namespace ImageProcessorCore.Tests [Fact] public void ImageShouldApplyInvertFilterInBox() { - const string path = "TestOutput/Invert"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Invert"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Filters/KodachromeTest.cs b/tests/ImageProcessorCore.Tests/Processors/Filters/KodachromeTest.cs index 584dac56c2..1a5e9c12b7 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Filters/KodachromeTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Filters/KodachromeTest.cs @@ -14,11 +14,7 @@ namespace ImageProcessorCore.Tests [Fact] public void ImageShouldApplyKodachromeFilter() { - const string path = "TestOutput/Kodachrome"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Kodachrome"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Filters/LomographTest.cs b/tests/ImageProcessorCore.Tests/Processors/Filters/LomographTest.cs index e9e4b183bb..22cfff4937 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Filters/LomographTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Filters/LomographTest.cs @@ -14,11 +14,7 @@ namespace ImageProcessorCore.Tests [Fact] public void ImageShouldApplyLomographFilter() { - const string path = "TestOutput/Lomograph"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Lomograph"); foreach (TestFile file in Files) { @@ -35,11 +31,8 @@ namespace ImageProcessorCore.Tests [Fact] public void ImageShouldApplyLomographFilterInBox() { - const string path = "TestOutput/Lomograph"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Lomograph"); + foreach (TestFile file in Files) { string filename = file.GetFileName("InBox"); diff --git a/tests/ImageProcessorCore.Tests/Processors/Filters/PolaroidTest.cs b/tests/ImageProcessorCore.Tests/Processors/Filters/PolaroidTest.cs index 21714ae244..ee85ae929c 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Filters/PolaroidTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Filters/PolaroidTest.cs @@ -14,11 +14,7 @@ namespace ImageProcessorCore.Tests [Fact] public void ImageShouldApplyPolaroidFilter() { - const string path = "TestOutput/Polaroid"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Polaroid"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Filters/SaturationTest.cs b/tests/ImageProcessorCore.Tests/Processors/Filters/SaturationTest.cs index d2faa233f2..7609f36164 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Filters/SaturationTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Filters/SaturationTest.cs @@ -22,11 +22,7 @@ namespace ImageProcessorCore.Tests [MemberData("SaturationValues")] public void ImageShouldApplySaturationFilter(int value) { - const string path = "TestOutput/Saturation"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Saturation"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Filters/SepiaTest.cs b/tests/ImageProcessorCore.Tests/Processors/Filters/SepiaTest.cs index 742cf95f25..6329c3b663 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Filters/SepiaTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Filters/SepiaTest.cs @@ -14,11 +14,7 @@ namespace ImageProcessorCore.Tests [Fact] public void ImageShouldApplySepiaFilter() { - const string path = "TestOutput/Sepia"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Sepia"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Filters/VignetteTest.cs b/tests/ImageProcessorCore.Tests/Processors/Filters/VignetteTest.cs index dbe0e9a460..9fbe024ca7 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Filters/VignetteTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Filters/VignetteTest.cs @@ -14,11 +14,7 @@ namespace ImageProcessorCore.Tests [Fact] public void ImageShouldApplyVignetteFilter() { - const string path = "TestOutput/Vignette"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Vignette"); foreach (TestFile file in Files) { @@ -35,11 +31,7 @@ namespace ImageProcessorCore.Tests [Fact] public void ImageShouldApplyVignetteFilterColor() { - const string path = "TestOutput/Vignette"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Vignette"); foreach (TestFile file in Files) { @@ -57,11 +49,7 @@ namespace ImageProcessorCore.Tests [Fact] public void ImageShouldApplyVignetteFilterRadius() { - const string path = "TestOutput/Vignette"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Vignette"); foreach (TestFile file in Files) { @@ -79,11 +67,7 @@ namespace ImageProcessorCore.Tests [Fact] public void ImageShouldApplyVignetteFilterInBox() { - const string path = "TestOutput/Vignette"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Vignette"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Samplers/AutoOrientTests.cs b/tests/ImageProcessorCore.Tests/Processors/Samplers/AutoOrientTests.cs index e9d93ac3c0..43e4b0b190 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Samplers/AutoOrientTests.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Samplers/AutoOrientTests.cs @@ -28,11 +28,7 @@ namespace ImageProcessorCore.Tests [MemberData("OrientationValues")] public void ImageShouldFlip(RotateType rotateType, FlipType flipType, ushort orientation) { - const string path = "TestOutput/AutoOrient"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("AutoOrient"); string file = TestImages.Bmp.F; diff --git a/tests/ImageProcessorCore.Tests/Processors/Samplers/CropTest.cs b/tests/ImageProcessorCore.Tests/Processors/Samplers/CropTest.cs index b0601251a0..f9a3751ad1 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Samplers/CropTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Samplers/CropTest.cs @@ -14,11 +14,7 @@ namespace ImageProcessorCore.Tests [Fact] public void ImageShouldApplyCropSampler() { - const string path = "TestOutput/Crop"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Crop"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Samplers/DetectEdgesTest.cs b/tests/ImageProcessorCore.Tests/Processors/Samplers/DetectEdgesTest.cs index 1aaca4f083..2f5858f327 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Samplers/DetectEdgesTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Samplers/DetectEdgesTest.cs @@ -30,11 +30,7 @@ namespace ImageProcessorCore.Tests [MemberData(nameof(DetectEdgesFilters))] public void ImageShouldApplyDetectEdgesFilter(EdgeDetection detector) { - const string path = "TestOutput/DetectEdges"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("DetectEdges"); foreach (TestFile file in Files) { @@ -53,11 +49,7 @@ namespace ImageProcessorCore.Tests [MemberData("DetectEdgesFilters")] public void ImageShouldApplyDetectEdgesFilterInBox(EdgeDetection detector) { - const string path = "TestOutput/DetectEdges"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("DetectEdges"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Samplers/EntropyCropTest.cs b/tests/ImageProcessorCore.Tests/Processors/Samplers/EntropyCropTest.cs index 482e4459e6..a491cc768c 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Samplers/EntropyCropTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Samplers/EntropyCropTest.cs @@ -22,11 +22,7 @@ namespace ImageProcessorCore.Tests [MemberData("EntropyCropValues")] public void ImageShouldApplyEntropyCropSampler(float value) { - const string path = "TestOutput/EntropyCrop"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("EntropyCrop"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Samplers/FlipTests.cs b/tests/ImageProcessorCore.Tests/Processors/Samplers/FlipTests.cs index 427b5b6349..e41915ab0f 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Samplers/FlipTests.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Samplers/FlipTests.cs @@ -23,11 +23,7 @@ namespace ImageProcessorCore.Tests [MemberData("FlipValues")] public void ImageShouldFlip(FlipType flipType) { - const string path = "TestOutput/Flip"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Flip"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Samplers/GuassianBlurTest.cs b/tests/ImageProcessorCore.Tests/Processors/Samplers/GuassianBlurTest.cs index dc13968be0..faca177351 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Samplers/GuassianBlurTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Samplers/GuassianBlurTest.cs @@ -22,11 +22,7 @@ namespace ImageProcessorCore.Tests [MemberData("GuassianBlurValues")] public void ImageShouldApplyGuassianBlurFilter(int value) { - const string path = "TestOutput/GuassianBlur"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("GuassianBlur"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Samplers/GuassianSharpenTest.cs b/tests/ImageProcessorCore.Tests/Processors/Samplers/GuassianSharpenTest.cs index 341f97ac4c..78aa5ca01a 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Samplers/GuassianSharpenTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Samplers/GuassianSharpenTest.cs @@ -22,11 +22,7 @@ namespace ImageProcessorCore.Tests [MemberData("GuassianSharpenValues")] public void ImageShouldApplyGuassianSharpenFilter(int value) { - const string path = "TestOutput/GuassianSharpen"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("GuassianSharpen"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Samplers/OilPaintTest.cs b/tests/ImageProcessorCore.Tests/Processors/Samplers/OilPaintTest.cs index 1d07945d2b..3ff2fe2cf1 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Samplers/OilPaintTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Samplers/OilPaintTest.cs @@ -23,11 +23,7 @@ namespace ImageProcessorCore.Tests [MemberData(nameof(OilPaintValues))] public void ImageShouldApplyOilPaintFilter(Tuple value) { - const string path = "TestOutput/OilPaint"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("OilPaint"); foreach (TestFile file in Files) { @@ -46,11 +42,7 @@ namespace ImageProcessorCore.Tests [MemberData(nameof(OilPaintValues))] public void ImageShouldApplyOilPaintFilterInBox(Tuple value) { - const string path = "TestOutput/OilPaint"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("OilPaint"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Samplers/PadTest.cs b/tests/ImageProcessorCore.Tests/Processors/Samplers/PadTest.cs index 4cafac33ce..ff17083905 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Samplers/PadTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Samplers/PadTest.cs @@ -14,11 +14,7 @@ namespace ImageProcessorCore.Tests [Fact] public void ImageShouldApplyPadSampler() { - const string path = "TestOutput/Pad"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Pad"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Samplers/PixelateTest.cs b/tests/ImageProcessorCore.Tests/Processors/Samplers/PixelateTest.cs index 71a9941990..45986ad4af 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Samplers/PixelateTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Samplers/PixelateTest.cs @@ -22,11 +22,7 @@ namespace ImageProcessorCore.Tests [MemberData(nameof(PixelateValues))] public void ImageShouldApplyPixelateFilter(int value) { - const string path = "TestOutput/Pixelate"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Pixelate"); foreach (TestFile file in Files) { @@ -45,11 +41,7 @@ namespace ImageProcessorCore.Tests [MemberData(nameof(PixelateValues))] public void ImageShouldApplyPixelateFilterInBox(int value) { - const string path = "TestOutput/Pixelate"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Pixelate"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Samplers/ResizeTests.cs b/tests/ImageProcessorCore.Tests/Processors/Samplers/ResizeTests.cs index b1870abca0..1fec1f63b5 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Samplers/ResizeTests.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Samplers/ResizeTests.cs @@ -11,8 +11,6 @@ namespace ImageProcessorCore.Tests public class ResizeTests : FileTestBase { - private const string path = "TestOutput/Resize"; - public static readonly TheoryData ReSamplers = new TheoryData { @@ -37,10 +35,7 @@ namespace ImageProcessorCore.Tests [MemberData("ReSamplers")] public void ImageShouldResize(string name, IResampler sampler) { - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Resize"); foreach (TestFile file in Files) { @@ -62,10 +57,7 @@ namespace ImageProcessorCore.Tests { name = name + "-FixedWidth"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Resize"); foreach (TestFile file in Files) { @@ -86,10 +78,7 @@ namespace ImageProcessorCore.Tests { name = name + "-FixedHeight"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Resize"); foreach (TestFile file in Files) { @@ -110,10 +99,7 @@ namespace ImageProcessorCore.Tests { name = name + "-CropWidth"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Resize"); foreach (TestFile file in Files) { @@ -140,10 +126,7 @@ namespace ImageProcessorCore.Tests { name = name + "-CropHeight"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Resize"); foreach (TestFile file in Files) { @@ -170,10 +153,7 @@ namespace ImageProcessorCore.Tests { name = name + "-Pad"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Resize"); foreach (TestFile file in Files) { @@ -200,10 +180,7 @@ namespace ImageProcessorCore.Tests { name = name + "-BoxPad"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Resize"); foreach (TestFile file in Files) { @@ -231,10 +208,7 @@ namespace ImageProcessorCore.Tests { name = name + "Max"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Resize"); foreach (TestFile file in Files) { @@ -262,10 +236,7 @@ namespace ImageProcessorCore.Tests { name = name + "-Min"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Resize"); foreach (TestFile file in Files) { @@ -293,10 +264,7 @@ namespace ImageProcessorCore.Tests { name = name + "Stretch"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Resize"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Samplers/RotateFlipTest.cs b/tests/ImageProcessorCore.Tests/Processors/Samplers/RotateFlipTest.cs index e3cdeb9982..db9ae17e08 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Samplers/RotateFlipTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Samplers/RotateFlipTest.cs @@ -25,11 +25,7 @@ namespace ImageProcessorCore.Tests [MemberData("RotateFlipValues")] public void ImageShouldRotateFlip(RotateType rotateType, FlipType flipType) { - const string path = "TestOutput/RotateFlip"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("RotateFlip"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Samplers/RotateTest.cs b/tests/ImageProcessorCore.Tests/Processors/Samplers/RotateTest.cs index 1ff24919f9..954d133b00 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Samplers/RotateTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Samplers/RotateTest.cs @@ -31,11 +31,7 @@ namespace ImageProcessorCore.Tests [MemberData("RotateFloatValues")] public void ImageShouldApplyRotateSampler(float value) { - const string path = "TestOutput/Rotate"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Rotate"); foreach (TestFile file in Files) { @@ -54,11 +50,7 @@ namespace ImageProcessorCore.Tests [MemberData("RotateEnumValues")] public void ImageShouldApplyRotateSampler(RotateType value) { - const string path = "TestOutput/Rotate"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Rotate"); foreach (TestFile file in Files) { diff --git a/tests/ImageProcessorCore.Tests/Processors/Samplers/SkewTest.cs b/tests/ImageProcessorCore.Tests/Processors/Samplers/SkewTest.cs index 3410ef1cfd..360ae650f6 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Samplers/SkewTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Samplers/SkewTest.cs @@ -22,11 +22,7 @@ namespace ImageProcessorCore.Tests [MemberData("SkewValues")] public void ImageShouldApplySkewSampler(float x, float y) { - const string path = "TestOutput/Skew"; - if (!Directory.Exists(path)) - { - Directory.CreateDirectory(path); - } + string path = CreateOutputDirectory("Skew"); // Matches live example // http://www.w3schools.com/css/tryit.asp?filename=trycss3_transform_skew