Merge branch 'loaded-branch'
[moon.git] / test / 2.0 / moon-unit / System.Windows / SizeTest.cs
blobecf85d236d0803e923bd18105d949c2523885595
1 using System;
2 using System.Net;
3 using System.Windows;
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
18 [TestClass]
19 public class SizeTest
21 [TestMethod]
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));
36 s = Size.Empty;
37 s.Width = 10;
38 Assert.AreEqual (false, s.IsEmpty);
41 [TestMethod]
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));
49 [TestMethod]
50 [MoonlightBug]
51 public void NaNValuesTest ()
53 Size nan = new Size (Double.NaN, Double.NaN);
54 Assert.AreEqual (nan, new Size (Double.NaN, Double.NaN));
57 [TestMethod]
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 ();
69 [TestMethod]
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 ());
75 Size s = Size.Empty;
76 s.Width = Double.NaN;
77 Assert.AreEqual (Concat (Double.NaN, Double.NegativeInfinity), s.ToString ());
80 [TestMethod]
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)");