Moving WindowsBase into the mcs tree
[mono.git] / mcs / class / WindowsBase / Test / System.Windows / Int32RectTest.cs
1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
8 // 
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 // 
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 //
20 // Copyright (c) 2007 Novell, Inc. (http://www.novell.com)
21 //
22 // Authors:
23 //      Chris Toshok (toshok@ximian.com)
24 //
25
26 using System;
27 using System.Windows;
28 using System.Windows.Media;
29 using NUnit.Framework;
30
31 namespace MonoTests.System.Windows {
32
33         [TestFixture]
34         [Category ("NotWorking")]
35         public class Int32RectTest
36         {
37                 [Test]
38                 public void Ctor_Accessor ()
39                 {
40                         Int32Rect r;
41
42                         r = new Int32Rect (10, 15, 20, 30);
43                         Assert.AreEqual (10, r.X);
44                         Assert.AreEqual (15, r.Y);
45                         Assert.AreEqual (20, r.Width);
46                         Assert.AreEqual (30, r.Height);
47                 }
48
49                 [Test]
50                 public void Ctor_NegativeWidth ()
51                 {
52                         new Int32Rect (10, 10, -10, 10);
53                 }
54
55                 [Test]
56                 public void Ctor_NegativeHeight ()
57                 {
58                         new Int32Rect (10, 10, 10, -10);
59                 }
60
61                 [Test]
62                 public void Empty ()
63                 {
64                         Int32Rect r = Int32Rect.Empty;
65                         Assert.AreEqual (0, r.X);
66                         Assert.AreEqual (0, r.Y);
67                         Assert.AreEqual (0, r.Width);
68                         Assert.AreEqual (0, r.Height);
69                 }
70
71                 [Test]
72                 public void ModifyEmpty_x ()
73                 {
74                         Int32Rect r = Int32Rect.Empty;
75                         r.X = 5;
76                 }
77
78                 [Test]
79                 public void ModifyEmpty_y ()
80                 {
81                         Int32Rect r = Int32Rect.Empty;
82                         r.Y = 5;
83                 }
84
85                 [Test]
86                 public void ModifyEmpty_width ()
87                 {
88                         Int32Rect r = Int32Rect.Empty;
89                         r.Width = 5;
90                 }
91
92                 [Test]
93                 public void ModifyEmpty_height ()
94                 {
95                         Int32Rect r = Int32Rect.Empty;
96                         r.Height = 5;
97                 }
98
99                 [Test]
100                 public void ModifyEmpty_negative_width ()
101                 {
102                         Int32Rect r = Int32Rect.Empty;
103                         r.Width = -5;
104                 }
105
106                 [Test]
107                 public void ModifyEmpty_negative_height ()
108                 {
109                         Int32Rect r = Int32Rect.Empty;
110                         r.Height = -5;
111                 }
112
113
114                 [Test]
115                 public void Modify_negative_width ()
116                 {
117                         Int32Rect r = new Int32Rect (0, 0, 10, 10);
118                         r.Width = -5;
119                 }
120
121                 [Test]
122                 public void Modify_negative_height ()
123                 {
124                         Int32Rect r = new Int32Rect (0, 0, 10, 10);
125                         r.Height = -5;
126                 }
127
128                 [Test]
129                 public void IsEmpty ()
130                 {
131                         Assert.IsTrue (Int32Rect.Empty.IsEmpty);
132                         Assert.IsTrue ((new Int32Rect (0, 0, 0, 0)).IsEmpty);
133                         Assert.IsFalse ((new Int32Rect (5, 5, 5, 5)).IsEmpty);
134                 }
135
136                 [Test]
137                 public void ToStringTest ()
138                 {
139                         Int32Rect r = new Int32Rect (1, 2, 3, 4);
140                         Assert.AreEqual ("1,2,3,4", r.ToString());
141
142                         Assert.AreEqual ("Empty", Int32Rect.Empty.ToString());
143                 }
144
145                 [Test]
146                 public void Parse ()
147                 {
148                         Int32Rect r = Int32Rect.Parse ("1, 2, 3, 4");
149                         Assert.AreEqual (new Int32Rect (1, 2, 3, 4), r);
150                 }
151
152                 [Test]
153                 public void ParseNegative ()
154                 {
155                         Int32Rect.Parse ("1, 2, -3, -4");
156                 }
157
158                 [Test]
159                 public void Equals ()
160                 {
161                         Int32Rect r1 = new Int32Rect (1, 2, 3, 4);
162                         Int32Rect r2 = r1;
163
164                         Assert.IsTrue (r1.Equals (r1));
165
166                         r2.X = 0;
167                         Assert.IsFalse (r1.Equals (r2));
168                         r2.X = r1.X;
169
170                         r2.Y = 0;
171                         Assert.IsFalse (r1.Equals (r2));
172                         r2.Y = r1.Y;
173
174                         r2.Width = 0;
175                         Assert.IsFalse (r1.Equals (r2));
176                         r2.Width = r1.Width;
177
178                         r2.Height = 0;
179                         Assert.IsFalse (r1.Equals (r2));
180                         r2.Height = r1.Height;
181
182                         Assert.IsFalse (r1.Equals (new object()));
183                 }
184         }
185 }