3 using System.Windows.Converters;
6 namespace MonoTests.System.Windows {
9 public class PointValueSerializerTest
12 public void CanConvertFromString ()
14 var serializer = new PointValueSerializer ();
15 Assert.IsTrue (serializer.CanConvertFromString ("", null));
19 public void CanConvertToString ()
21 var serializer = new PointValueSerializer ();
22 Assert.IsTrue (serializer.CanConvertToString (new Point (0, 0), null));
23 Assert.IsFalse (serializer.CanConvertToString ("", null));
27 public void ConvertFromString ()
29 var serializer = new PointValueSerializer ();
30 object obj = serializer.ConvertFromString ("3.14,4.15", null);
31 Assert.AreEqual (typeof (Point), obj.GetType ());
32 Assert.AreEqual (new Point (3.14, 4.15), obj);
36 public void RoundTripConvert()
38 var serializer = new PointValueSerializer ();
39 var Point = new Point (1.234, 2.678);
40 var obj = serializer.ConvertFromString (serializer.ConvertToString (Point, null), null);
41 Assert.AreEqual (Point, obj);
45 [ExpectedException (typeof (FormatException))]
46 public void ConvertFromStringShouldThrowExceptionWhenStringHasInvalidFormat ()
48 var serializer = new PointValueSerializer ();
49 serializer.ConvertFromString ("a,b", null);
53 [ExpectedException (typeof (NotSupportedException))]
54 public void ConvertFromStringShouldThrowExceptionWhenStringIsNull ()
56 var serializer = new PointValueSerializer ();
57 serializer.ConvertFromString (null, null);
61 [ExpectedException (typeof (NotSupportedException))]
62 public void ConvertToStringShouldThrowExceptionWhenInvalidType ()
64 var serializer = new PointValueSerializer ();
65 serializer.ConvertToString (10, null);