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:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
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.
20 // Copyright (c) 2007 Novell, Inc. (http://www.novell.com)
23 // Chris Toshok (toshok@ximian.com)
28 using System.Windows.Media;
29 using NUnit.Framework;
31 namespace MonoTests.System.Windows {
34 public class Int32RectTest
37 public void Ctor_Accessor ()
41 r = new Int32Rect (10, 15, 20, 30);
42 Assert.AreEqual (10, r.X);
43 Assert.AreEqual (15, r.Y);
44 Assert.AreEqual (20, r.Width);
45 Assert.AreEqual (30, r.Height);
49 public void Ctor_NegativeWidth ()
51 new Int32Rect (10, 10, -10, 10);
55 public void Ctor_NegativeHeight ()
57 new Int32Rect (10, 10, 10, -10);
63 Int32Rect r = Int32Rect.Empty;
64 Assert.AreEqual (0, r.X);
65 Assert.AreEqual (0, r.Y);
66 Assert.AreEqual (0, r.Width);
67 Assert.AreEqual (0, r.Height);
71 public void ModifyEmpty_x ()
73 Int32Rect r = Int32Rect.Empty;
78 public void ModifyEmpty_y ()
80 Int32Rect r = Int32Rect.Empty;
85 public void ModifyEmpty_width ()
87 Int32Rect r = Int32Rect.Empty;
92 public void ModifyEmpty_height ()
94 Int32Rect r = Int32Rect.Empty;
99 public void ModifyEmpty_negative_width ()
101 Int32Rect r = Int32Rect.Empty;
106 public void ModifyEmpty_negative_height ()
108 Int32Rect r = Int32Rect.Empty;
114 public void Modify_negative_width ()
116 Int32Rect r = new Int32Rect (0, 0, 10, 10);
121 public void Modify_negative_height ()
123 Int32Rect r = new Int32Rect (0, 0, 10, 10);
128 public void IsEmpty ()
130 Assert.IsTrue (Int32Rect.Empty.IsEmpty);
131 Assert.IsTrue ((new Int32Rect (0, 0, 0, 0)).IsEmpty);
132 Assert.IsFalse ((new Int32Rect (5, 5, 5, 5)).IsEmpty);
136 public void ToStringTest ()
138 Int32Rect r = new Int32Rect (1, 2, 3, 4);
139 Assert.AreEqual ("1,2,3,4", r.ToString());
141 Assert.AreEqual ("Empty", Int32Rect.Empty.ToString());
145 [Category ("NotWorking")]
148 Int32Rect r = Int32Rect.Parse ("1, 2, 3, 4");
149 Assert.AreEqual (new Int32Rect (1, 2, 3, 4), r);
153 [Category ("NotWorking")]
154 public void ParseNegative ()
156 Int32Rect.Parse ("1, 2, -3, -4");
160 public void Equals ()
162 Int32Rect r1 = new Int32Rect (1, 2, 3, 4);
165 Assert.IsTrue (r1.Equals (r1));
168 Assert.IsFalse (r1.Equals (r2));
172 Assert.IsFalse (r1.Equals (r2));
176 Assert.IsFalse (r1.Equals (r2));
180 Assert.IsFalse (r1.Equals (r2));
181 r2.Height = r1.Height;
183 Assert.IsFalse (r1.Equals (new object()));