Skip to content

Commit 6035e48

Browse files
committed
Fixed unit tests for Point/Rect/Size extensions
1 parent e5cb937 commit 6035e48

File tree

3 files changed

+43
-42
lines changed

3 files changed

+43
-42
lines changed

UnitTests/UnitTests.UWP/Extensions/Test_PointExtensions.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,51 +13,51 @@ public class Test_PointExtensions
1313
{
1414
[TestCategory("PointExtensions")]
1515
[TestMethod]
16-
[DataRow(0d, 0d, 0, 0)]
17-
[DataRow(0d, 0d, 22, 6.89d)]
16+
[DataRow(0d, 0d, 0d, 0d)]
17+
[DataRow(0d, 0d, 22d, 6.89d)]
1818
[DataRow(3.14d, 6.55f, 3838d, 3.24724928d)]
19-
[DataRow(double.MinValue, double.Epsilon, 22, 0.3248d)]
20-
public static void Test_PointExtensions_ToRect_FromWidthHeight(double width, double height, int x, int y)
19+
[DataRow(double.MaxValue / 2, double.Epsilon, 22d, 0.3248d)]
20+
public void Test_PointExtensions_ToRect_FromWidthHeight(double width, double height, double x, double y)
2121
{
22-
Point p = new Point(x, y);
22+
Point p = new(x, y);
2323
Rect
2424
a = p.ToRect(width, height),
25-
b = new Rect(x, y, width, height);
25+
b = new(x, y, width, height);
2626

2727
Assert.AreEqual(a, b);
2828
}
2929

3030
[TestCategory("SizeExtensions")]
3131
[TestMethod]
32-
[DataRow(0d, 0d, 0, 0)]
33-
[DataRow(0d, 0d, 22, 6.89d)]
32+
[DataRow(0d, 0d, 0d, 0d)]
33+
[DataRow(0d, 0d, 22d, 6.89d)]
3434
[DataRow(3.14d, 6.55f, 3838d, 3.24724928d)]
35-
[DataRow(double.MinValue, double.Epsilon, 22, 0.3248d)]
36-
public static void Test_PointExtensions_ToRect_FromPoint(double width, double height, int x, int y)
35+
[DataRow(double.MaxValue / 2, double.Epsilon, 22, 0.3248d)]
36+
public void Test_PointExtensions_ToRect_FromPoint(double width, double height, double x, double y)
3737
{
3838
Point
39-
p1 = new Point(x, y),
40-
p2 = new Point(x + width, y + height);
39+
p1 = new(x, y),
40+
p2 = new(x + width, y + height);
4141
Rect
4242
a = p1.ToRect(p2),
43-
b = new Rect(p1, p2);
43+
b = new(p1, p2);
4444

4545
Assert.AreEqual(a, b);
4646
}
4747

4848
[TestCategory("SizeExtensions")]
4949
[TestMethod]
50-
[DataRow(0d, 0d, 0, 0)]
51-
[DataRow(0d, 0d, 22, 6.89d)]
50+
[DataRow(0d, 0d, 0d, 0d)]
51+
[DataRow(0d, 0d, 22d, 6.89d)]
5252
[DataRow(3.14d, 6.55f, 3838d, 3.24724928d)]
53-
[DataRow(double.MinValue, double.Epsilon, 22, 0.3248d)]
54-
public static void Test_PointExtensions_ToRect_FromSize(double width, double height, int x, int y)
53+
[DataRow(double.MaxValue / 2, double.Epsilon, 22, 0.3248d)]
54+
public void Test_PointExtensions_ToRect_FromSize(double width, double height, double x, double y)
5555
{
56-
Point p = new Point(x, y);
57-
Size s = new Size(width, height);
56+
Point p = new(x, y);
57+
Size s = new(width, height);
5858
Rect
5959
a = p.ToRect(s),
60-
b = new Rect(p, s);
60+
b = new(p, s);
6161

6262
Assert.AreEqual(a, b);
6363
}

UnitTests/UnitTests.UWP/Extensions/Test_RectExtensions.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ public class Test_RectExtensions
2626
[DataRow(0, 0, 2, 2, -2, 2, 2, 2, true)]// Left bottom corner(0, 2) intersection.
2727
[DataRow(0, 0, 2, 2, 3, 0, 2, 2, false)]// No intersection.
2828
[SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1117:Parameters should be on same line or separate lines", Justification = "Put the parameters of the same rectangle on the same line is clearer.")]
29-
public static void Test_RectExtensions_IntersectsWith(
29+
public void Test_RectExtensions_IntersectsWith(
3030
double rect1X, double rect1Y, double rect1Width, double rect1Height,
3131
double rect2X, double rect2Y, double rect2Width, double rect2Height,
3232
bool shouldIntersectsWith)
3333
{
34-
var rect1 = new Rect(rect1X, rect1Y, rect1Width, rect1Height);
35-
var rect2 = new Rect(rect2X, rect2Y, rect2Width, rect2Height);
36-
var isIntersectsWith = rect1.IntersectsWith(rect2);
34+
Rect rect1 = new(rect1X, rect1Y, rect1Width, rect1Height);
35+
Rect rect2 = new(rect2X, rect2Y, rect2Width, rect2Height);
36+
bool isIntersectsWith = rect1.IntersectsWith(rect2);
37+
3738
Assert.IsTrue(isIntersectsWith == shouldIntersectsWith);
3839
}
3940
}

UnitTests/UnitTests.UWP/Extensions/Test_SizeExtensions.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,47 +14,47 @@ public class Test_SizeExtensions
1414
[TestCategory("SizeExtensions")]
1515
[TestMethod]
1616
[DataRow(0d, 0d)]
17-
[DataRow(3.14d, 6.55f)]
18-
[DataRow(double.MinValue, double.Epsilon)]
19-
public static void Test_SizeExtensions_ToRect_FromSize(double width, double height)
17+
[DataRow(3.14d, 6.55d)]
18+
[DataRow(double.MaxValue / 2, double.Epsilon)]
19+
public void Test_SizeExtensions_ToRect_FromSize(double width, double height)
2020
{
21-
Size s = new Size(width, height);
21+
Size s = new(width, height);
2222
Rect
2323
a = s.ToRect(),
24-
b = new Rect(0, 0, s.Width, s.Height);
24+
b = new(0, 0, s.Width, s.Height);
2525

2626
Assert.AreEqual(a, b);
2727
}
2828

2929
[TestCategory("SizeExtensions")]
3030
[TestMethod]
31-
[DataRow(0d, 0d, 0, 0)]
32-
[DataRow(0d, 0d, 22, 6.89d)]
31+
[DataRow(0d, 0d, 0d, 0d)]
32+
[DataRow(0d, 0d, 22d, 6.89d)]
3333
[DataRow(3.14d, 6.55f, 3838d, 3.24724928d)]
34-
[DataRow(double.MinValue, double.Epsilon, 22, 0.3248d)]
35-
public static void Test_SizeExtensions_ToRect_FromSizeAndPosition(double width, double height, int x, int y)
34+
[DataRow(double.MaxValue / 2, double.Epsilon, 22, 0.3248d)]
35+
public void Test_SizeExtensions_ToRect_FromSizeAndPosition(double width, double height, double x, double y)
3636
{
37-
Size s = new Size(width, height);
37+
Size s = new(width, height);
3838
Rect
3939
a = s.ToRect(x, y),
40-
b = new Rect(x, y, s.Width, s.Height);
40+
b = new(x, y, s.Width, s.Height);
4141

4242
Assert.AreEqual(a, b);
4343
}
4444

4545
[TestCategory("SizeExtensions")]
4646
[TestMethod]
47-
[DataRow(0d, 0d, 0, 0)]
48-
[DataRow(0d, 0d, 22, 6.89d)]
47+
[DataRow(0d, 0d, 0d, 0d)]
48+
[DataRow(0d, 0d, 22d, 6.89d)]
4949
[DataRow(3.14d, 6.55f, 3838d, 3.24724928d)]
50-
[DataRow(double.MinValue, double.Epsilon, 22, 0.3248d)]
51-
public static void Test_SizeExtensions_ToRect_FromSizeAndPoint(double width, double height, int x, int y)
50+
[DataRow(double.MaxValue / 2, double.Epsilon, 22d, 0.3248d)]
51+
public void Test_SizeExtensions_ToRect_FromSizeAndPoint(double width, double height, double x, double y)
5252
{
53-
Point p = new Point(x, y);
54-
Size s = new Size(width, height);
53+
Point p = new(x, y);
54+
Size s = new(width, height);
5555
Rect
5656
a = s.ToRect(p),
57-
b = new Rect(p, s);
57+
b = new(p, s);
5858

5959
Assert.AreEqual(a, b);
6060
}

0 commit comments

Comments
 (0)