4 using System
.Windows
.Controls
;
5 using System
.Windows
.Documents
;
6 using System
.Windows
.Ink
;
7 using System
.Windows
.Input
;
8 using System
.Windows
.Media
;
9 using System
.Windows
.Media
.Animation
;
10 using System
.Windows
.Shapes
;
11 using System
.Collections
.Generic
;
12 using Mono
.Moonlight
.UnitTesting
;
13 using Microsoft
.VisualStudio
.TestTools
.UnitTesting
;
16 namespace MoonTest
.System
.Windows
22 public void EmptyTest ()
24 Assert
.AreEqual (Double
.NegativeInfinity
, Size
.Empty
.Width
);
25 Assert
.AreEqual (Double
.NegativeInfinity
, Size
.Empty
.Height
);
27 Assert
.AreEqual (false, (new Size(0,0)).IsEmpty
);
29 Assert
.Throws (delegate { new Size (-1, 5); }
, typeof (ArgumentException
));
30 Assert
.Throws (delegate { new Size (Double.MinValue, Double.MinValue); }
, typeof (ArgumentException
));
31 Assert
.Throws (delegate { new Size (Double.NegativeInfinity, Double.NegativeInfinity); }
, typeof (ArgumentException
));
33 Size s
= new Size (0,0);
34 Assert
.Throws (delegate { s.Width = Double.NegativeInfinity; }
, typeof (ArgumentException
));
38 Assert
.AreEqual (false, s
.IsEmpty
);
42 public void NaNTest ()
44 Size test
= new Size (Double
.NaN
, Double
.NaN
);
45 Assert
.AreEqual (true, Double
.IsNaN (test
.Width
));
46 Assert
.AreEqual (true, Double
.IsNaN (test
.Height
));
51 public void NaNValuesTest ()
53 Size nan
= new Size (Double
.NaN
, Double
.NaN
);
54 Assert
.AreEqual (nan
, new Size (Double
.NaN
, Double
.NaN
));
58 public void ToStringTest ()
60 Assert
.AreEqual (Concat (5, 5), new Size (5, 5).ToString ());
61 Assert
.AreEqual (Concat (5.234124, 5234235), new Size (5.234124, 5234235).ToString ());
64 static string Concat (double a
, double b
)
66 return a
.ToString () + "," + b
.ToString ();
70 public void SpecialToString ()
72 Assert
.AreEqual (Concat (Double
.NaN
, Double
.NaN
), new Size (Double
.NaN
, Double
.NaN
).ToString ());
73 Assert
.AreEqual ("Empty", Size
.Empty
.ToString ());
77 Assert
.AreEqual (Concat (Double
.NaN
, Double
.NegativeInfinity
), s
.ToString ());
81 public void QuasiEquality ()
83 Size expected
= new Size (25, 25);
84 Size actual
= new Size (25.000000000000001, 25.000000000000001);
85 Assert
.IsTrue (expected
.Equals (actual
), "Equals(Size)");
86 Assert
.IsTrue (actual
.Equals ((object)expected
), "Equals(object)");
88 actual
= new Size (25.00000000000001, 25.00000000000001);
89 Assert
.IsFalse (expected
.Equals (actual
), "not-Equals(Size)");
90 Assert
.IsFalse (actual
.Equals ((object) expected
), "not-Equals(object)");