Browse Source

Fixing Unit tests.

Former-commit-id: 238822ef315612de5201703a61709a325c629a4a
af/merge-core
James South 12 years ago
parent
commit
e5cfcf7c36
  1. 11
      src/ImageProcessor.Tests/RegularExpressionUnitTests.cs
  2. 1
      src/ImageProcessor/ImageProcessor.csproj
  3. 104
      src/ImageProcessor/Imaging/RotateLayer.cs
  4. 8
      src/ImageProcessor/Processors/Alpha.cs
  5. 8
      src/ImageProcessor/Processors/AutoRotate.cs
  6. 8
      src/ImageProcessor/Processors/BackgroundColor.cs
  7. 8
      src/ImageProcessor/Processors/Brightness.cs
  8. 8
      src/ImageProcessor/Processors/Contrast.cs
  9. 8
      src/ImageProcessor/Processors/Crop.cs
  10. 8
      src/ImageProcessor/Processors/Filter.cs
  11. 8
      src/ImageProcessor/Processors/Flip.cs
  12. 8
      src/ImageProcessor/Processors/Format.cs
  13. 8
      src/ImageProcessor/Processors/GaussianBlur.cs
  14. 8
      src/ImageProcessor/Processors/GaussianSharpen.cs
  15. 8
      src/ImageProcessor/Processors/Quality.cs
  16. 12
      src/ImageProcessor/Processors/Resize.cs
  17. 12
      src/ImageProcessor/Processors/Rotate.cs
  18. 10
      src/ImageProcessor/Processors/RoundedCorners.cs
  19. 10
      src/ImageProcessor/Processors/Saturation.cs
  20. 8
      src/ImageProcessor/Processors/Tint.cs
  21. 1
      src/ImageProcessor/Processors/Vignette.cs
  22. 8
      src/ImageProcessor/Processors/Watermark.cs

11
src/ImageProcessor.Tests/RegularExpressionUnitTests.cs

@ -8,12 +8,9 @@ namespace ImageProcessor.Tests
{
#region Using
using System.Drawing;
using ImageProcessor.Configuration;
using ImageProcessor.Imaging;
using ImageProcessor.Imaging.Filters;
using ImageProcessor.Imaging.Formats;
using ImageProcessor.Processors;
using Microsoft.VisualStudio.TestTools.UnitTesting;
#endregion
@ -169,14 +166,14 @@ namespace ImageProcessor.Tests
public void TestRotateRegex()
{
const string Querystring = "rotate=270";
RotateLayer expected = new RotateLayer(270, Color.Transparent);
const int Expected = 270;
Web.Processors.Rotate rotate = new Web.Processors.Rotate();
rotate.MatchRegexIndex(Querystring);
RotateLayer actual = rotate.Processor.DynamicParameter;
int actual = rotate.Processor.DynamicParameter;
Assert.AreEqual(expected, actual);
Assert.AreEqual(Expected, actual);
}
/// <summary>
@ -218,4 +215,4 @@ namespace ImageProcessor.Tests
}
#endregion
}
}
}

1
src/ImageProcessor/ImageProcessor.csproj

@ -106,7 +106,6 @@
<Compile Include="Imaging\ImageUtils.cs" />
<Compile Include="Imaging\ResizeMode.cs" />
<Compile Include="Imaging\ResponseType.cs" />
<Compile Include="Imaging\RotateLayer.cs" />
<Compile Include="Imaging\RoundedCornerLayer.cs" />
<Compile Include="Imaging\TextLayer.cs" />
<Compile Include="Imaging\OctreeQuantizer.cs" />

104
src/ImageProcessor/Imaging/RotateLayer.cs

@ -1,104 +0,0 @@
// -----------------------------------------------------------------------
// <copyright file="RotateLayer.cs" company="James South">
// Copyright (c) James South.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// -----------------------------------------------------------------------
namespace ImageProcessor.Imaging
{
#region Using
using System.Drawing;
#endregion
/// <summary>
/// Encapsulates the properties required to rotate an image.
/// </summary>
public class RotateLayer
{
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="RotateLayer"/> class.
/// </summary>
public RotateLayer()
{
this.BackgroundColor = Color.Transparent;
}
/// <summary>
/// Initializes a new instance of the <see cref="RotateLayer"/> class.
/// </summary>
/// <param name="angle">
/// The angle at which to rotate the image.
/// </param>
public RotateLayer(int angle)
{
this.Angle = angle;
this.BackgroundColor = Color.Transparent;
}
/// <summary>
/// Initializes a new instance of the <see cref="RotateLayer"/> class.
/// </summary>
/// <param name="angle">
/// The angle at which to rotate the image.
/// </param>
/// <param name="backgroundColor">
/// The <see cref="T:System.Drawing.Color"/> to set as the background color.
/// <remarks>Used for image formats that do not support transparency</remarks>
/// </param>
public RotateLayer(int angle, Color backgroundColor)
{
this.Angle = angle;
this.BackgroundColor = backgroundColor;
}
#endregion
#region Properties
/// <summary>
/// Gets or sets the angle at which to rotate the image.
/// </summary>
public int Angle { get; set; }
/// <summary>
/// Gets or sets the background color.
/// </summary>
public Color BackgroundColor { get; set; }
#endregion
/// <summary>
/// Returns a value that indicates whether the specified object is an
/// <see cref="RotateLayer"/> object that is equivalent to
/// this <see cref="RotateLayer"/> object.
/// </summary>
/// <param name="obj">
/// The object to test.
/// </param>
/// <returns>
/// True if the given object is an <see cref="RotateLayer"/> object that is equivalent to
/// this <see cref="RotateLayer"/> object; otherwise, false.
/// </returns>
public override bool Equals(object obj)
{
RotateLayer rotate = obj as RotateLayer;
if (rotate == null)
{
return false;
}
return this.Angle == rotate.Angle && this.BackgroundColor == rotate.BackgroundColor;
}
/// <summary>
/// Returns a hash code value that represents this object.
/// </summary>
/// <returns>
/// A hash code that represents this object.
/// </returns>
public override int GetHashCode()
{
return this.Angle.GetHashCode() + this.BackgroundColor.GetHashCode();
}
}
}

8
src/ImageProcessor/Processors/Alpha.cs

@ -19,6 +19,14 @@ namespace ImageProcessor.Processors
/// </summary>
public class Alpha : IGraphicsProcessor
{
/// <summary>
/// Initializes a new instance of the <see cref="Alpha"/> class.
/// </summary>
public Alpha()
{
this.Settings = new Dictionary<string, string>();
}
/// <summary>
/// Gets or sets DynamicParameter.
/// </summary>

8
src/ImageProcessor/Processors/AutoRotate.cs

@ -21,6 +21,14 @@ namespace ImageProcessor.Processors
/// </summary>
public class AutoRotate : IGraphicsProcessor
{
/// <summary>
/// Initializes a new instance of the <see cref="AutoRotate"/> class.
/// </summary>
public AutoRotate()
{
this.Settings = new Dictionary<string, string>();
}
/// <summary>
/// Gets or sets DynamicParameter.
/// </summary>

8
src/ImageProcessor/Processors/BackgroundColor.cs

@ -18,6 +18,14 @@ namespace ImageProcessor.Processors
/// </summary>
public class BackgroundColor : IGraphicsProcessor
{
/// <summary>
/// Initializes a new instance of the <see cref="BackgroundColor"/> class.
/// </summary>
public BackgroundColor()
{
this.Settings = new Dictionary<string, string>();
}
/// <summary>
/// Gets or sets the DynamicParameter.
/// </summary>

8
src/ImageProcessor/Processors/Brightness.cs

@ -19,6 +19,14 @@ namespace ImageProcessor.Processors
/// </summary>
public class Brightness : IGraphicsProcessor
{
/// <summary>
/// Initializes a new instance of the <see cref="Brightness"/> class.
/// </summary>
public Brightness()
{
this.Settings = new Dictionary<string, string>();
}
/// <summary>
/// Gets or sets DynamicParameter.
/// </summary>

8
src/ImageProcessor/Processors/Contrast.cs

@ -19,6 +19,14 @@ namespace ImageProcessor.Processors
/// </summary>
public class Contrast : IGraphicsProcessor
{
/// <summary>
/// Initializes a new instance of the <see cref="Contrast"/> class.
/// </summary>
public Contrast()
{
this.Settings = new Dictionary<string, string>();
}
/// <summary>
/// Gets or sets DynamicParameter.
/// </summary>

8
src/ImageProcessor/Processors/Crop.cs

@ -23,6 +23,14 @@ namespace ImageProcessor.Processors
/// </summary>
public class Crop : IGraphicsProcessor
{
/// <summary>
/// Initializes a new instance of the <see cref="Crop"/> class.
/// </summary>
public Crop()
{
this.Settings = new Dictionary<string, string>();
}
/// <summary>
/// Gets or sets DynamicParameter.
/// </summary>

8
src/ImageProcessor/Processors/Filter.cs

@ -22,6 +22,14 @@ namespace ImageProcessor.Processors
/// </summary>
public class Filter : IGraphicsProcessor
{
/// <summary>
/// Initializes a new instance of the <see cref="Filter"/> class.
/// </summary>
public Filter()
{
this.Settings = new Dictionary<string, string>();
}
/// <summary>
/// Gets or sets DynamicParameter.
/// </summary>

8
src/ImageProcessor/Processors/Flip.cs

@ -21,6 +21,14 @@ namespace ImageProcessor.Processors
/// </summary>
public class Flip : IGraphicsProcessor
{
/// <summary>
/// Initializes a new instance of the <see cref="Flip"/> class.
/// </summary>
public Flip()
{
this.Settings = new Dictionary<string, string>();
}
/// <summary>
/// Gets or sets DynamicParameter.
/// </summary>

8
src/ImageProcessor/Processors/Format.cs

@ -25,6 +25,14 @@ namespace ImageProcessor.Processors
/// </summary>
public class Format : IGraphicsProcessor
{
/// <summary>
/// Initializes a new instance of the <see cref="Format"/> class.
/// </summary>
public Format()
{
this.Settings = new Dictionary<string, string>();
}
/// <summary>
/// Gets or sets DynamicParameter.
/// </summary>

8
src/ImageProcessor/Processors/GaussianBlur.cs

@ -19,6 +19,14 @@ namespace ImageProcessor.Processors
/// </summary>
public class GaussianBlur : IGraphicsProcessor
{
/// <summary>
/// Initializes a new instance of the <see cref="GaussianBlur"/> class.
/// </summary>
public GaussianBlur()
{
this.Settings = new Dictionary<string, string>();
}
/// <summary>
/// Gets or sets the DynamicParameter.
/// </summary>

8
src/ImageProcessor/Processors/GaussianSharpen.cs

@ -19,6 +19,14 @@ namespace ImageProcessor.Processors
/// </summary>
public class GaussianSharpen : IGraphicsProcessor
{
/// <summary>
/// Initializes a new instance of the <see cref="GaussianSharpen"/> class.
/// </summary>
public GaussianSharpen()
{
this.Settings = new Dictionary<string, string>();
}
/// <summary>
/// Gets or sets the DynamicParameter.
/// </summary>

8
src/ImageProcessor/Processors/Quality.cs

@ -20,6 +20,14 @@ namespace ImageProcessor.Processors
/// </summary>
public class Quality : IGraphicsProcessor
{
/// <summary>
/// Initializes a new instance of the <see cref="Quality"/> class.
/// </summary>
public Quality()
{
this.Settings = new Dictionary<string, string>();
}
/// <summary>
/// Gets or sets DynamicParameter.
/// </summary>

12
src/ImageProcessor/Processors/Resize.cs

@ -10,7 +10,6 @@
namespace ImageProcessor.Processors
{
#region Using
using System;
using System.Collections.Generic;
using System.Drawing;
@ -19,14 +18,20 @@ namespace ImageProcessor.Processors
using System.Globalization;
using System.Linq;
using ImageProcessor.Imaging;
#endregion
/// <summary>
/// Resizes an image to the given dimensions.
/// </summary>
public class Resize : IGraphicsProcessor
{
#region IGraphicsProcessor Members
/// <summary>
/// Initializes a new instance of the <see cref="Resize"/> class.
/// </summary>
public Resize()
{
this.Settings = new Dictionary<string, string>();
}
/// <summary>
/// Gets or sets DynamicParameter.
/// </summary>
@ -77,7 +82,6 @@ namespace ImageProcessor.Processors
return this.ResizeImage(factory, width, height, defaultMaxWidth, defaultMaxHeight, this.RestrictedSizes, mode, anchor, upscale, centerCoordinates);
}
#endregion
/// <summary>
/// The resize image.

12
src/ImageProcessor/Processors/Rotate.cs

@ -10,19 +10,24 @@
namespace ImageProcessor.Processors
{
#region Using
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
#endregion
/// <summary>
/// Encapsulates methods to rotate an image.
/// </summary>
public class Rotate : IGraphicsProcessor
{
#region IGraphicsProcessor members
/// <summary>
/// Initializes a new instance of the <see cref="Rotate"/> class.
/// </summary>
public Rotate()
{
this.Settings = new Dictionary<string, string>();
}
/// <summary>
/// Gets or sets DynamicParameter.
/// </summary>
@ -80,7 +85,6 @@ namespace ImageProcessor.Processors
return image;
}
#endregion
#region Private Methods
/// <summary>

10
src/ImageProcessor/Processors/RoundedCorners.cs

@ -14,8 +14,6 @@ namespace ImageProcessor.Processors
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Globalization;
using System.Text.RegularExpressions;
using ImageProcessor.Imaging;
#endregion
@ -24,6 +22,14 @@ namespace ImageProcessor.Processors
/// </summary>
public class RoundedCorners : IGraphicsProcessor
{
/// <summary>
/// Initializes a new instance of the <see cref="RoundedCorners"/> class.
/// </summary>
public RoundedCorners()
{
this.Settings = new Dictionary<string, string>();
}
/// <summary>
/// Gets or sets DynamicParameter.
/// </summary>

10
src/ImageProcessor/Processors/Saturation.cs

@ -24,7 +24,14 @@ namespace ImageProcessor.Processors
/// </remarks>
public class Saturation : IGraphicsProcessor
{
#region IGraphicsProcessor Members
/// <summary>
/// Initializes a new instance of the <see cref="Saturation"/> class.
/// </summary>
public Saturation()
{
this.Settings = new Dictionary<string, string>();
}
/// <summary>
/// Gets or sets DynamicParameter.
/// </summary>
@ -129,6 +136,5 @@ namespace ImageProcessor.Processors
return image;
}
#endregion
}
}

8
src/ImageProcessor/Processors/Tint.cs

@ -20,6 +20,14 @@ namespace ImageProcessor.Processors
/// </summary>
public class Tint : IGraphicsProcessor
{
/// <summary>
/// Initializes a new instance of the <see cref="Tint"/> class.
/// </summary>
public Tint()
{
this.Settings = new Dictionary<string, string>();
}
/// <summary>
/// Gets or sets DynamicParameter.
/// </summary>

1
src/ImageProcessor/Processors/Vignette.cs

@ -29,6 +29,7 @@ namespace ImageProcessor.Processors
public Vignette()
{
this.DynamicParameter = Color.Black;
this.Settings = new Dictionary<string, string>();
}
/// <summary>

8
src/ImageProcessor/Processors/Watermark.cs

@ -21,6 +21,14 @@ namespace ImageProcessor.Processors
/// </summary>
public class Watermark : IGraphicsProcessor
{
/// <summary>
/// Initializes a new instance of the <see cref="Watermark"/> class.
/// </summary>
public Watermark()
{
this.Settings = new Dictionary<string, string>();
}
/// <summary>
/// Gets or sets DynamicParameter.
/// </summary>

Loading…
Cancel
Save