Skip to content

Commit 23e223c

Browse files
committed
Added unit tests for Point extensions
1 parent a8de01a commit 23e223c

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using Windows.Foundation;
6+
using Microsoft.Toolkit.Uwp.Extensions;
7+
using Microsoft.VisualStudio.TestTools.UnitTesting;
8+
9+
namespace UnitTests.Extensions
10+
{
11+
[TestClass]
12+
public class Test_PointExtensions
13+
{
14+
[TestCategory("PointExtensions")]
15+
[TestMethod]
16+
[DataRow(0d, 0d, 0, 0)]
17+
[DataRow(0d, 0d, 22, 6.89d)]
18+
[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)
21+
{
22+
Point p = new Point(x, y);
23+
Rect
24+
a = p.ToRect(width, height),
25+
b = new Rect(x, y, width, height);
26+
27+
Assert.AreEqual(a, b);
28+
}
29+
30+
[TestCategory("SizeExtensions")]
31+
[TestMethod]
32+
[DataRow(0d, 0d, 0, 0)]
33+
[DataRow(0d, 0d, 22, 6.89d)]
34+
[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)
37+
{
38+
Point p = new Point(x, y);
39+
Size s = new Size(width, height);
40+
Rect
41+
a = p.ToRect(s),
42+
b = new Rect(p, s);
43+
44+
Assert.AreEqual(a, b);
45+
}
46+
}
47+
}

UnitTests/UnitTests.UWP/UnitTests.UWP.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
<Compile Include="Converters\Test_StringFormatConverter.cs" />
139139
<Compile Include="Converters\Test_TypeToObjectConverter.cs" />
140140
<Compile Include="Extensions\Helpers\ObjectWithNullableBoolProperty.cs" />
141+
<Compile Include="Extensions\Test_PointExtensions.cs" />
141142
<Compile Include="Extensions\Test_SizeExtensions.cs" />
142143
<Compile Include="Extensions\Test_BitmapIconExtensionMarkupExtension.cs" />
143144
<Compile Include="Extensions\Test_FontIconSourceExtensionMarkupExtension.cs" />

0 commit comments

Comments
 (0)