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 {
37 public void Ctor_Accessors ()
39 Size s = new Size (10, 20);
40 Assert.AreEqual (10, s.Width);
41 Assert.AreEqual (20, s.Height);
47 Size s = new Size (10, 20);
49 Assert.IsTrue (s.Equals (s));
50 Assert.IsTrue (s.Equals (new Size (10, 20)));
52 Assert.IsTrue (Size.Equals (s, s));
54 Assert.IsFalse (s.Equals (new Size (5, 10)));
55 Assert.IsFalse (Size.Equals (s, new Size (5, 10)));
57 Assert.IsFalse (s.Equals (new object()));
61 [ExpectedException (typeof (ArgumentException))]
62 public void Ctor_negative_width()
68 [ExpectedException (typeof (ArgumentException))]
69 public void Ctor_negative_height()
75 public void Modify_width ()
77 Size s = new Size (10, 10);
79 Assert.AreEqual (new Size (20, 10), s);
83 [ExpectedException (typeof (InvalidOperationException))]
84 public void ModifyEmpty_width ()
91 [ExpectedException (typeof (ArgumentException))]
92 public void Modify_negative_width ()
94 Size s = new Size (10, 10);
99 public void Modify_height ()
101 Size s = new Size (10, 10);
103 Assert.AreEqual (new Size (10, 20), s);
107 [ExpectedException (typeof (InvalidOperationException))]
108 public void ModifyEmpty_height ()
115 [ExpectedException (typeof (ArgumentException))]
116 public void Modify_negative_height ()
118 Size s = new Size (10, 10);
123 [Category ("NotWorking")]
126 Assert.AreEqual (new Size (1, 2), Size.Parse ("1, 2"));
130 [ExpectedException (typeof (ArgumentException))]
131 public void ParseNegative ()
133 Assert.AreEqual (new Size (-1, 2), Size.Parse ("-1, 2"));
137 public void ToStringTest ()
139 Assert.AreEqual ("1,2", (new Size (1, 2)).ToString());
145 Assert.AreEqual (Double.NegativeInfinity, Size.Empty.Width);
146 Assert.AreEqual (Double.NegativeInfinity, Size.Empty.Height);
150 public void IsEmpty ()
152 Assert.IsTrue (Size.Empty.IsEmpty);
153 Assert.IsFalse ((new Size (10, 10)).IsEmpty);
154 Assert.IsFalse ((new Size (0, 0)).IsEmpty);