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_SizeExtensions
13
+ {
14
+ [ TestCategory ( "SizeExtensions" ) ]
15
+ [ TestMethod ]
16
+ [ 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 )
20
+ {
21
+ Size s = new Size ( width , height ) ;
22
+ Rect
23
+ a = s . ToRect ( ) ,
24
+ b = new Rect ( 0 , 0 , s . Width , s . Height ) ;
25
+
26
+ Assert . AreEqual ( a , b ) ;
27
+ }
28
+
29
+ [ TestCategory ( "SizeExtensions" ) ]
30
+ [ TestMethod ]
31
+ [ DataRow ( 0d , 0d , 0 , 0 ) ]
32
+ [ DataRow ( 0d , 0d , 22 , 6.89d ) ]
33
+ [ 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 )
36
+ {
37
+ Size s = new Size ( width , height ) ;
38
+ Rect
39
+ a = s . ToRect ( x , y ) ,
40
+ b = new Rect ( x , y , s . Width , s . Height ) ;
41
+
42
+ Assert . AreEqual ( a , b ) ;
43
+ }
44
+
45
+ [ TestCategory ( "SizeExtensions" ) ]
46
+ [ TestMethod ]
47
+ [ DataRow ( 0d , 0d , 0 , 0 ) ]
48
+ [ DataRow ( 0d , 0d , 22 , 6.89d ) ]
49
+ [ 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 )
52
+ {
53
+ Point p = new Point ( x , y ) ;
54
+ Size s = new Size ( width , height ) ;
55
+ Rect
56
+ a = s . ToRect ( p ) ,
57
+ b = new Rect ( p , s ) ;
58
+
59
+ Assert . AreEqual ( a , b ) ;
60
+ }
61
+ }
62
+ }
0 commit comments