Skip to content

Commit ef5cdc5

Browse files
Added a few unit tests
1 parent faf28db commit ef5cdc5

File tree

1 file changed

+53
-3
lines changed

1 file changed

+53
-3
lines changed

src/ImageProcessor.Tests/RegularExpressionUnitTests.cs

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,40 @@ public void TestAlphaRegex()
3939
Assert.AreEqual(Expected, actual);
4040
}
4141

42+
/// <summary>
43+
/// The brightness regex unit test.
44+
/// </summary>
45+
[TestMethod]
46+
public void TestBrightnessRegex()
47+
{
48+
const string Querystring = "brightness=56";
49+
const int Expected = 56;
50+
51+
Brightness brightness = new Brightness();
52+
brightness.MatchRegexIndex(Querystring);
53+
54+
int actual = brightness.DynamicParameter;
55+
56+
Assert.AreEqual(Expected, actual);
57+
}
58+
59+
/// <summary>
60+
/// The contrast regex unit test.
61+
/// </summary>
62+
[TestMethod]
63+
public void TestContrastRegex()
64+
{
65+
const string Querystring = "contrast=56";
66+
const int Expected = 56;
67+
68+
Contrast contrast = new Contrast();
69+
contrast.MatchRegexIndex(Querystring);
70+
71+
int actual = contrast.DynamicParameter;
72+
73+
Assert.AreEqual(Expected, actual);
74+
}
75+
4276
/// <summary>
4377
/// The rotate regex unit test.
4478
/// </summary>
@@ -139,9 +173,25 @@ public void TestRotateRegex()
139173

140174
RotateLayer actual = rotate.DynamicParameter;
141175

142-
// Can't use are equal on rotatelayer for some reason so test the two properties.
143-
Assert.AreEqual(expected.Angle, actual.Angle);
144-
Assert.AreEqual(expected.BackgroundColor, actual.BackgroundColor);
176+
Assert.AreEqual(expected, actual);
177+
}
178+
179+
180+
/// <summary>
181+
/// The rounded corners regex unit test.
182+
/// </summary>
183+
[TestMethod]
184+
public void TestRoundedCornersRegex()
185+
{
186+
const string Querystring = "roundedcorners=30";
187+
RoundedCornerLayer expected = new RoundedCornerLayer(30, true, true, true, true);
188+
189+
RoundedCorners roundedCorners = new RoundedCorners();
190+
roundedCorners.MatchRegexIndex(Querystring);
191+
192+
RoundedCornerLayer actual = roundedCorners.DynamicParameter;
193+
194+
Assert.AreEqual(expected, actual);
145195
}
146196
#endregion
147197
}

0 commit comments

Comments
 (0)