[WindowsBase] Use InvariantCulture for ConvertTo/ToString tests
[mono.git] / mcs / class / WindowsBase / Test / System.Windows.Media / MatrixConverterTest.cs
1 using NUnit.Framework;
2 using System;
3 using System.Globalization;
4 using System.Windows.Media;
5
6 namespace MonoTests.System.Windows.Media {
7
8         [TestFixture]
9         public class MatrixConverterTest {
10                 const double DELTA = 0.000000001d;
11
12                 void CheckMatrix (Matrix expected, Matrix actual)
13                 {
14                         Assert.AreEqual (expected.M11, actual.M11, DELTA);
15                         Assert.AreEqual (expected.M12, actual.M12, DELTA);
16                         Assert.AreEqual (expected.M21, actual.M21, DELTA);
17                         Assert.AreEqual (expected.M22, actual.M22, DELTA);
18                         Assert.AreEqual (expected.OffsetX, actual.OffsetX, DELTA);
19                         Assert.AreEqual (expected.OffsetY, actual.OffsetY, DELTA);
20                 }
21
22                 [Test]
23                 public void CanConvertFrom ()
24                 {
25                         var conv = new MatrixConverter ();
26                         Assert.IsTrue (conv.CanConvertFrom (typeof (string)));
27                         Assert.IsFalse (conv.CanConvertFrom (typeof (Matrix)));
28                 }
29
30                 [Test]
31                 public void CanConvertTo ()
32                 {
33                         var conv = new MatrixConverter ();
34                         Assert.IsTrue (conv.CanConvertTo (typeof (string)));
35                         Assert.IsFalse (conv.CanConvertTo (typeof (Matrix)));
36                 }
37
38                 [Test]
39                 public void ConvertFrom ()
40                 {
41                         var conv = new MatrixConverter ();
42                         object obj = conv.ConvertFrom ("1, 2, 3, 4, 5, 6");
43                         Assert.AreEqual (typeof (Matrix), obj.GetType ());
44                         CheckMatrix (new Matrix (1, 2, 3, 4, 5, 6), (Matrix)obj);
45                 }
46
47                 [Test]
48                 [ExpectedException (typeof (NotSupportedException))]
49                 public void ConvertFromInvalidType ()
50                 {
51                         var conv = new MatrixConverter ();
52                         conv.ConvertFrom (new Matrix (10, 20, 30, 40, 50, 60));
53                 }
54
55                 [Test]
56                 public void ConvertTo ()
57                 {
58                         var conv = new MatrixConverter ();
59                         var matrix = new Matrix (1, 2, 3, 4, 5, 6);
60                         object obj = conv.ConvertTo (null, CultureInfo.InvariantCulture, matrix, typeof (string));
61                         Assert.AreEqual (typeof (string), obj.GetType ());
62                         Assert.AreEqual ("1,2,3,4,5,6", (string)obj);
63                 }
64         }
65 }