Browse Source

Added Tests for code that was moved.

Former-commit-id: e9adf42e34c17e9518c927a32384b56b915dc43d
Former-commit-id: 27a5087388b5222b321a13e5bf4931c6b59d56df
Former-commit-id: 93f08ba739fd4d68d921817cddfae19d59cece59
af/merge-core
dirk 10 years ago
parent
commit
3ce2d964e5
  1. 48
      tests/ImageProcessorCore.Tests/Processors/Samplers/FlipTests.cs
  2. 42
      tests/ImageProcessorCore.Tests/Processors/Samplers/RotateTest.cs

48
tests/ImageProcessorCore.Tests/Processors/Samplers/FlipTests.cs

@ -0,0 +1,48 @@
// <copyright file="RotateFlipTest.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageProcessorCore.Tests
{
using System.IO;
using Xunit;
public class FlipTest : FileTestBase
{
public static readonly TheoryData<FlipType> FlipValues
= new TheoryData<FlipType>
{
{ 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);
}
}
}
}
}
}

42
tests/ImageProcessorCore.Tests/Processors/Samplers/RotateTest.cs

@ -11,15 +11,25 @@ namespace ImageProcessorCore.Tests
public class RotateTest : FileTestBase
{
public static readonly TheoryData<float> RotateValues
= new TheoryData<float>
public static readonly TheoryData<float> RotateFloatValues
= new TheoryData<float>
{
170 ,
-170 ,
90 ,
};
public static readonly TheoryData<RotateType> RotateEnumValues
= new TheoryData<RotateType>
{
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);
}
}
}
}
}
}
Loading…
Cancel
Save