From 3ce2d964e59a1bbe6e015a1eb26ee2d34bfa5259 Mon Sep 17 00:00:00 2001 From: dirk Date: Sat, 13 Aug 2016 15:48:40 +0200 Subject: [PATCH] Added Tests for code that was moved. Former-commit-id: e9adf42e34c17e9518c927a32384b56b915dc43d Former-commit-id: 27a5087388b5222b321a13e5bf4931c6b59d56df Former-commit-id: 93f08ba739fd4d68d921817cddfae19d59cece59 --- .../Processors/Samplers/FlipTests.cs | 48 +++++++++++++++++++ .../Processors/Samplers/RotateTest.cs | 42 ++++++++++++++-- 2 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 tests/ImageProcessorCore.Tests/Processors/Samplers/FlipTests.cs diff --git a/tests/ImageProcessorCore.Tests/Processors/Samplers/FlipTests.cs b/tests/ImageProcessorCore.Tests/Processors/Samplers/FlipTests.cs new file mode 100644 index 000000000..5402644e5 --- /dev/null +++ b/tests/ImageProcessorCore.Tests/Processors/Samplers/FlipTests.cs @@ -0,0 +1,48 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageProcessorCore.Tests +{ + using System.IO; + + using Xunit; + + public class FlipTest : FileTestBase + { + public static readonly TheoryData FlipValues + = new TheoryData + { + { FlipType.None }, + { FlipType.Vertical }, + { FlipType.Horizontal }, + }; + + [Theory] + [MemberData("FlipValues")] + public void ImageShouldFlip(FlipType flipType) + { + const string path = "TestOutput/Flip"; + if (!Directory.Exists(path)) + { + Directory.CreateDirectory(path); + } + + foreach (string file in Files) + { + using (FileStream stream = File.OpenRead(file)) + { + string filename = Path.GetFileNameWithoutExtension(file) + "-" + flipType + Path.GetExtension(file); + + Image image = new Image(stream); + using (FileStream output = File.OpenWrite($"{path}/{filename}")) + { + image.Flip(flipType, this.ProgressUpdate) + .Save(output); + } + } + } + } + } +} \ No newline at end of file diff --git a/tests/ImageProcessorCore.Tests/Processors/Samplers/RotateTest.cs b/tests/ImageProcessorCore.Tests/Processors/Samplers/RotateTest.cs index 7b38656b1..61ffdfd93 100644 --- a/tests/ImageProcessorCore.Tests/Processors/Samplers/RotateTest.cs +++ b/tests/ImageProcessorCore.Tests/Processors/Samplers/RotateTest.cs @@ -11,15 +11,25 @@ namespace ImageProcessorCore.Tests public class RotateTest : FileTestBase { - public static readonly TheoryData RotateValues - = new TheoryData + public static readonly TheoryData RotateFloatValues + = new TheoryData { 170 , -170 , + 90 , + }; + + public static readonly TheoryData RotateEnumValues + = new TheoryData + { + RotateType.None, + RotateType.Rotate90, + RotateType.Rotate180, + RotateType.Rotate270 }; [Theory] - [MemberData("RotateValues")] + [MemberData("RotateFloatValues")] public void ImageShouldApplyRotateSampler(float value) { const string path = "TestOutput/Rotate"; @@ -43,5 +53,31 @@ namespace ImageProcessorCore.Tests } } } + + [Theory] + [MemberData("RotateEnumValues")] + public void ImageShouldApplyRotateSampler(RotateType value) + { + const string path = "TestOutput/Rotate"; + if (!Directory.Exists(path)) + { + Directory.CreateDirectory(path); + } + + foreach (string file in Files) + { + using (FileStream stream = File.OpenRead(file)) + { + string filename = Path.GetFileNameWithoutExtension(file) + "-" + value + Path.GetExtension(file); + + Image image = new Image(stream); + using (FileStream output = File.OpenWrite($"{path}/{filename}")) + { + image.Rotate(value) + .Save(output); + } + } + } + } } } \ No newline at end of file