Browse Source

Renames unit test methods

Former-commit-id: 7816ef72a421f858ec6f470211ebca4f88e45a3d
Former-commit-id: fb37580f9ba2dc289061af5ef4f33dddcf09d5d8
pull/17/head
Thomas Broust 12 years ago
parent
commit
4603dd67cd
  1. 2
      src/ImageProcessor.UnitTests/Configuration/ImageProcessorBootrapperTests.cs
  2. 2
      src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs
  3. 2
      src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs
  4. 60
      src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs
  5. 28
      src/ImageProcessor.UnitTests/Imaging/ColorUnitTests.cs

2
src/ImageProcessor.UnitTests/Configuration/ImageProcessorBootrapperTests.cs

@ -21,7 +21,7 @@ namespace ImageProcessor.UnitTests.Configuration
public class ImageProcessorBootrapperTests public class ImageProcessorBootrapperTests
{ {
[Test] [Test]
public void Singleton_is_instantiated() public void BoostrapperSingletonIsInstantiated()
{ {
ImageProcessorBootstrapper.Instance.SupportedImageFormats.Count().Should().BeGreaterThan(0, "because there should be supported image formats"); ImageProcessorBootstrapper.Instance.SupportedImageFormats.Count().Should().BeGreaterThan(0, "because there should be supported image formats");

2
src/ImageProcessor.UnitTests/Extensions/DoubleExtensionsUnitTests.cs

@ -29,7 +29,7 @@ namespace ImageProcessor.UnitTests.Extensions
[TestCase(1.5, 2)] [TestCase(1.5, 2)]
[TestCase(25.7, 26)] [TestCase(25.7, 26)]
[TestCase(1289047, 255)] [TestCase(1289047, 255)]
public void TestDoubleToByte(double input, byte expected) public void DoubleIsConvertedToByte(double input, byte expected)
{ {
byte result = input.ToByte(); byte result = input.ToByte();
Assert.AreEqual(expected, result); Assert.AreEqual(expected, result);

2
src/ImageProcessor.UnitTests/Extensions/IntegerExtensionsUnitTests.cs

@ -28,7 +28,7 @@ namespace ImageProcessor.UnitTests.Extensions
[TestCase(21, 0x15)] [TestCase(21, 0x15)]
[TestCase(190, 0xBE)] [TestCase(190, 0xBE)]
[TestCase(3156, 0xFF)] [TestCase(3156, 0xFF)]
public void ToByteTest(int input, byte expected) public void IntegerIsConvertedToByte(int input, byte expected)
{ {
byte result = input.ToByte(); byte result = input.ToByte();
Assert.AreEqual(expected, result); Assert.AreEqual(expected, result);

60
src/ImageProcessor.UnitTests/ImageFactoryUnitTests.cs

@ -40,7 +40,7 @@ namespace ImageProcessor.UnitTests
/// Tests the loading of image from a file /// Tests the loading of image from a file
/// </summary> /// </summary>
[Test] [Test]
public void TestLoadImageFromFile() public void ImageIsLoadedFromFile()
{ {
foreach (FileInfo file in this.ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
@ -58,7 +58,7 @@ namespace ImageProcessor.UnitTests
/// Tests the loading of image from a memory stream /// Tests the loading of image from a memory stream
/// </summary> /// </summary>
[Test] [Test]
public void TestLoadImageFromMemory() public void ImageIsLoadedFromMemoryStream()
{ {
foreach (FileInfo file in this.ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
@ -81,7 +81,7 @@ namespace ImageProcessor.UnitTests
/// Tests that the save method actually saves a file /// Tests that the save method actually saves a file
/// </summary> /// </summary>
[Test] [Test]
public void TestSaveToDisk() public void ImageIsSavedToDisk()
{ {
foreach (FileInfo file in this.ListInputFiles()) foreach (FileInfo file in this.ListInputFiles())
{ {
@ -102,7 +102,7 @@ namespace ImageProcessor.UnitTests
/// Tests that the save method actually writes to memory /// Tests that the save method actually writes to memory
/// </summary> /// </summary>
[Test] [Test]
public void TestSaveToMemory() public void ImageIsSavedToMemory()
{ {
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
{ {
@ -120,7 +120,7 @@ namespace ImageProcessor.UnitTests
/// Tests that a filter is really applied by checking that the image is modified /// Tests that a filter is really applied by checking that the image is modified
/// </summary> /// </summary>
[Test] [Test]
public void TestApplyEffectAlpha() public void AlphaIsModified()
{ {
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
{ {
@ -134,7 +134,7 @@ namespace ImageProcessor.UnitTests
/// Tests that brightness changes is really applied by checking that the image is modified /// Tests that brightness changes is really applied by checking that the image is modified
/// </summary> /// </summary>
[Test] [Test]
public void TestApplyEffectBrightness() public void BrightnessIsModified()
{ {
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
{ {
@ -148,7 +148,7 @@ namespace ImageProcessor.UnitTests
/// Tests that background color changes are really applied by checking that the image is modified /// Tests that background color changes are really applied by checking that the image is modified
/// </summary> /// </summary>
[Test] [Test]
public void TestApplyEffectBackgroundColor() public void BackgroundColorIsChanged()
{ {
ImageFactory imageFactory = new ImageFactory(); ImageFactory imageFactory = new ImageFactory();
imageFactory.Load(@"Images\text.png"); imageFactory.Load(@"Images\text.png");
@ -161,7 +161,7 @@ namespace ImageProcessor.UnitTests
/// Tests that a contrast change is really applied by checking that the image is modified /// Tests that a contrast change is really applied by checking that the image is modified
/// </summary> /// </summary>
[Test] [Test]
public void TestApplyEffectContrast() public void ContrastIsModified()
{ {
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
{ {
@ -175,7 +175,7 @@ namespace ImageProcessor.UnitTests
/// Tests that a saturation change is really applied by checking that the image is modified /// Tests that a saturation change is really applied by checking that the image is modified
/// </summary> /// </summary>
[Test] [Test]
public void TestApplyEffectSaturation() public void SaturationIsModified()
{ {
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
{ {
@ -189,7 +189,7 @@ namespace ImageProcessor.UnitTests
/// Tests that a tint change is really applied by checking that the image is modified /// Tests that a tint change is really applied by checking that the image is modified
/// </summary> /// </summary>
[Test] [Test]
public void TestApplyEffectTint() public void TintIsModified()
{ {
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
{ {
@ -203,7 +203,7 @@ namespace ImageProcessor.UnitTests
/// Tests that a vignette change is really applied by checking that the image is modified /// Tests that a vignette change is really applied by checking that the image is modified
/// </summary> /// </summary>
[Test] [Test]
public void TestApplyEffectVignette() public void VignetteEffectIsApplied()
{ {
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
{ {
@ -217,7 +217,7 @@ namespace ImageProcessor.UnitTests
/// Tests that a filter is really applied by checking that the image is modified /// Tests that a filter is really applied by checking that the image is modified
/// </summary> /// </summary>
[Test] [Test]
public void TestApplyEffectWatermark() public void WatermarkIsApplied()
{ {
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
{ {
@ -237,7 +237,7 @@ namespace ImageProcessor.UnitTests
/// Tests that a filter is really applied by checking that the image is modified /// Tests that a filter is really applied by checking that the image is modified
/// </summary> /// </summary>
[Test] [Test]
public void TestApplyEffectBlur() public void BlurEffectIsApplied()
{ {
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
{ {
@ -251,7 +251,7 @@ namespace ImageProcessor.UnitTests
/// Tests that a filter is really applied by checking that the image is modified /// Tests that a filter is really applied by checking that the image is modified
/// </summary> /// </summary>
[Test] [Test]
public void TestApplyEffectBlurWithLayer() public void BlurWithLayerIsApplied()
{ {
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
{ {
@ -265,7 +265,7 @@ namespace ImageProcessor.UnitTests
/// Tests that a filter is really applied by checking that the image is modified /// Tests that a filter is really applied by checking that the image is modified
/// </summary> /// </summary>
[Test] [Test]
public void TestApplyEffectSharpen() public void SharpenEffectIsApplied()
{ {
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
{ {
@ -279,7 +279,7 @@ namespace ImageProcessor.UnitTests
/// Tests that a filter is really applied by checking that the image is modified /// Tests that a filter is really applied by checking that the image is modified
/// </summary> /// </summary>
[Test] [Test]
public void TestApplyEffectSharpenWithLayer() public void SharpenWithLayerIsApplied()
{ {
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
{ {
@ -293,7 +293,7 @@ namespace ImageProcessor.UnitTests
/// Tests that all filters can be applied /// Tests that all filters can be applied
/// </summary> /// </summary>
[Test] [Test]
public void TestApplyEffectFilter() public void FilterIsApplied()
{ {
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
{ {
@ -327,7 +327,7 @@ namespace ImageProcessor.UnitTests
/// Tests that a filter is really applied by checking that the image is modified /// Tests that a filter is really applied by checking that the image is modified
/// </summary> /// </summary>
[Test] [Test]
public void TestRoundedCorners() public void RoundedCornersAreApplied()
{ {
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
{ {
@ -341,7 +341,7 @@ namespace ImageProcessor.UnitTests
/// Tests that the image is well resized using constraints /// Tests that the image is well resized using constraints
/// </summary> /// </summary>
[Test] [Test]
public void TestResizeConstraints() public void ImageIsResizedWithinConstraints()
{ {
const int MaxSize = 200; const int MaxSize = 200;
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
@ -356,7 +356,7 @@ namespace ImageProcessor.UnitTests
/// Tests that the image is well cropped /// Tests that the image is well cropped
/// </summary> /// </summary>
[Test] [Test]
public void TestCrop() public void ImageIsCropped()
{ {
const int MaxSize = 20; const int MaxSize = 20;
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
@ -374,7 +374,7 @@ namespace ImageProcessor.UnitTests
/// Tests that the image is well cropped /// Tests that the image is well cropped
/// </summary> /// </summary>
[Test] [Test]
public void TestCropWithCropLayer() public void ImageIsCroppedWithLayer()
{ {
const int MaxSize = 20; const int MaxSize = 20;
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
@ -392,7 +392,7 @@ namespace ImageProcessor.UnitTests
/// Tests that the image is flipped /// Tests that the image is flipped
/// </summary> /// </summary>
[Test] [Test]
public void TestFlip() public void ImageIsFlipped()
{ {
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
{ {
@ -415,7 +415,7 @@ namespace ImageProcessor.UnitTests
/// Tests that the image is resized /// Tests that the image is resized
/// </summary> /// </summary>
[Test] [Test]
public void TestResize() public void ImageIsResized()
{ {
const int NewSize = 150; const int NewSize = 150;
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
@ -431,7 +431,7 @@ namespace ImageProcessor.UnitTests
/// Tests that the image is resized /// Tests that the image is resized
/// </summary> /// </summary>
[Test] [Test]
public void TestResizeWithLayer() public void ImageIsResizedWithLayer()
{ {
const int NewSize = 150; const int NewSize = 150;
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
@ -447,7 +447,7 @@ namespace ImageProcessor.UnitTests
/// Tests that the image is resized /// Tests that the image is resized
/// </summary> /// </summary>
[Test] [Test]
public void TestRotate() public void ImageIsRotated()
{ {
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
{ {
@ -463,7 +463,7 @@ namespace ImageProcessor.UnitTests
/// Tests that the images hue has been altered. /// Tests that the images hue has been altered.
/// </summary> /// </summary>
[Test] [Test]
public void TestHue() public void HueIsModified()
{ {
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
{ {
@ -483,7 +483,7 @@ namespace ImageProcessor.UnitTests
/// Tests that the image has been pixelated. /// Tests that the image has been pixelated.
/// </summary> /// </summary>
[Test] [Test]
public void TestPixelate() public void PixelateEffectIsApplied()
{ {
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
{ {
@ -497,7 +497,7 @@ namespace ImageProcessor.UnitTests
/// Tests that the images quality has been set. /// Tests that the images quality has been set.
/// </summary> /// </summary>
[Test] [Test]
public void TestQuality() public void ImageQualityIsModified()
{ {
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
{ {
@ -513,7 +513,7 @@ namespace ImageProcessor.UnitTests
/// Tests that the image has had a color replaced. /// Tests that the image has had a color replaced.
/// </summary> /// </summary>
[Test] [Test]
public void TestReplaceColor() public void ColorIsReplaced()
{ {
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
{ {
@ -527,7 +527,7 @@ namespace ImageProcessor.UnitTests
/// Tests that the various edge detection algorithms are applied. /// Tests that the various edge detection algorithms are applied.
/// </summary> /// </summary>
[Test] [Test]
public void TestEdgeDetection() public void EdgeDetectionEffectIsApplied()
{ {
foreach (ImageFactory imageFactory in this.ListInputImages()) foreach (ImageFactory imageFactory in this.ListInputImages())
{ {

28
src/ImageProcessor.UnitTests/Imaging/ColorUnitTests.cs

@ -14,6 +14,7 @@ namespace ImageProcessor.UnitTests.Imaging
using System.Drawing; using System.Drawing;
using ImageProcessor.Imaging.Colors; using ImageProcessor.Imaging.Colors;
using NUnit.Framework; using NUnit.Framework;
using FluentAssertions;
/// <summary> /// <summary>
/// Test harness for the color classes. /// Test harness for the color classes.
@ -25,36 +26,36 @@ namespace ImageProcessor.UnitTests.Imaging
/// Tests the <see cref="RgbaColor"/> struct equality operators. /// Tests the <see cref="RgbaColor"/> struct equality operators.
/// </summary> /// </summary>
[Test] [Test]
public void TestRgbaEquality() public void RgbaColorImplementsEquals()
{ {
RgbaColor first = RgbaColor.FromColor(Color.White); RgbaColor first = RgbaColor.FromColor(Color.White);
RgbaColor second = RgbaColor.FromColor(Color.White); RgbaColor second = RgbaColor.FromColor(Color.White);
Assert.AreEqual(first, second); first.Equals(second).Should().BeTrue("because the color structure should implement Equals()");
} }
/// <summary> /// <summary>
/// Tests the <see cref="HslaColor"/> struct equality operators. /// Tests the <see cref="HslaColor"/> struct equality operators.
/// </summary> /// </summary>
[Test] [Test]
public void TestHslaEquality() public void HslaColorImplementsEquals()
{ {
HslaColor first = HslaColor.FromColor(Color.White); HslaColor first = HslaColor.FromColor(Color.White);
HslaColor second = HslaColor.FromColor(Color.White); HslaColor second = HslaColor.FromColor(Color.White);
Assert.AreEqual(first, second); first.Equals(second).Should().BeTrue("because the color structure should implement Equals()");
} }
/// <summary> /// <summary>
/// Tests the <see cref="YCbCrColor"/> struct equality operators. /// Tests the <see cref="YCbCrColor"/> struct equality operators.
/// </summary> /// </summary>
[Test] [Test]
public void TestYCbCrEquality() public void YCbCrColorImplementsEquals()
{ {
YCbCrColor first = YCbCrColor.FromColor(Color.White); YCbCrColor first = YCbCrColor.FromColor(Color.White);
YCbCrColor second = YCbCrColor.FromColor(Color.White); YCbCrColor second = YCbCrColor.FromColor(Color.White);
Assert.AreEqual(first, second); first.Equals(second).Should().BeTrue("because the color structure should implement Equals()");
} }
/// <summary> /// <summary>
@ -78,12 +79,13 @@ namespace ImageProcessor.UnitTests.Imaging
[TestCase("#FFFFBB")] [TestCase("#FFFFBB")]
[TestCase("#FF002B")] [TestCase("#FF002B")]
[TestCase("#00ABFF")] [TestCase("#00ABFF")]
public void TestHslaConversion(string expected) public void HslaColorShouldConvertToAndFromString(string expected)
{ {
Color color = ColorTranslator.FromHtml(expected); Color color = ColorTranslator.FromHtml(expected);
HslaColor hslaColor = HslaColor.FromColor(color); HslaColor hslaColor = HslaColor.FromColor(color);
string result = ColorTranslator.ToHtml(hslaColor); string result = ColorTranslator.ToHtml(hslaColor);
Assert.AreEqual(expected, result);
result.Should().Be(expected);
} }
/// <summary> /// <summary>
@ -107,12 +109,13 @@ namespace ImageProcessor.UnitTests.Imaging
[TestCase("#FFFFBB")] [TestCase("#FFFFBB")]
[TestCase("#FF002B")] [TestCase("#FF002B")]
[TestCase("#00ABFF")] [TestCase("#00ABFF")]
public void TestRgbaConversion(string expected) public void RgbaColorShouldConvertToAndFromString(string expected)
{ {
Color color = ColorTranslator.FromHtml(expected); Color color = ColorTranslator.FromHtml(expected);
RgbaColor rgbaColor = RgbaColor.FromColor(color); RgbaColor rgbaColor = RgbaColor.FromColor(color);
string result = ColorTranslator.ToHtml(rgbaColor); string result = ColorTranslator.ToHtml(rgbaColor);
Assert.AreEqual(expected, result);
result.Should().Be(expected);
} }
/// <summary> /// <summary>
@ -136,12 +139,13 @@ namespace ImageProcessor.UnitTests.Imaging
[TestCase("#FFFFBB")] [TestCase("#FFFFBB")]
[TestCase("#FF002B")] [TestCase("#FF002B")]
[TestCase("#00ABFF")] [TestCase("#00ABFF")]
public void TestYCbCrConversion(string expected) public void YCbCrColorShouldConvertToAndFromString(string expected)
{ {
Color color = ColorTranslator.FromHtml(expected); Color color = ColorTranslator.FromHtml(expected);
YCbCrColor yCbCrColor = YCbCrColor.FromColor(color); YCbCrColor yCbCrColor = YCbCrColor.FromColor(color);
string result = ColorTranslator.ToHtml(yCbCrColor); string result = ColorTranslator.ToHtml(yCbCrColor);
Assert.AreEqual(expected, result);
result.Should().Be(expected);
} }
} }
} }

Loading…
Cancel
Save