Imported Upstream version 5.8.0.22

Former-commit-id: df344e34b07851d296efb3e6604c8db42b6f7aa3
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-10-19 20:04:20 +00:00
parent 5f4a27cc8a
commit 7d05485754
5020 changed files with 114082 additions and 186061 deletions

View File

@@ -0,0 +1,65 @@
using NUnit.Framework;
using System;
using System.Globalization;
using System.Windows.Media;
namespace MonoTests.System.Windows.Media {
[TestFixture]
public class MatrixConverterTest {
const double DELTA = 0.000000001d;
void CheckMatrix (Matrix expected, Matrix actual)
{
Assert.AreEqual (expected.M11, actual.M11, DELTA);
Assert.AreEqual (expected.M12, actual.M12, DELTA);
Assert.AreEqual (expected.M21, actual.M21, DELTA);
Assert.AreEqual (expected.M22, actual.M22, DELTA);
Assert.AreEqual (expected.OffsetX, actual.OffsetX, DELTA);
Assert.AreEqual (expected.OffsetY, actual.OffsetY, DELTA);
}
[Test]
public void CanConvertFrom ()
{
var conv = new MatrixConverter ();
Assert.IsTrue (conv.CanConvertFrom (typeof (string)));
Assert.IsFalse (conv.CanConvertFrom (typeof (Matrix)));
}
[Test]
public void CanConvertTo ()
{
var conv = new MatrixConverter ();
Assert.IsTrue (conv.CanConvertTo (typeof (string)));
Assert.IsFalse (conv.CanConvertTo (typeof (Matrix)));
}
[Test]
public void ConvertFrom ()
{
var conv = new MatrixConverter ();
object obj = conv.ConvertFrom ("1, 2, 3, 4, 5, 6");
Assert.AreEqual (typeof (Matrix), obj.GetType ());
CheckMatrix (new Matrix (1, 2, 3, 4, 5, 6), (Matrix)obj);
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void ConvertFromInvalidType ()
{
var conv = new MatrixConverter ();
conv.ConvertFrom (new Matrix (10, 20, 30, 40, 50, 60));
}
[Test]
public void ConvertTo ()
{
var conv = new MatrixConverter ();
var matrix = new Matrix (1, 2, 3, 4, 5, 6);
object obj = conv.ConvertTo (null, CultureInfo.InvariantCulture, matrix, typeof (string));
Assert.AreEqual (typeof (string), obj.GetType ());
Assert.AreEqual ("1,2,3,4,5,6", (string)obj);
}
}
}

View File

@@ -24,6 +24,7 @@
//
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Media;
using NUnit.Framework;
@@ -158,7 +159,6 @@ namespace MonoTests.System.Windows.Media {
}
[Test]
[Category ("NotWorking")]
public void Parse ()
{
CheckMatrix (Matrix.Identity, Matrix.Parse ("Identity"));
@@ -348,7 +348,7 @@ namespace MonoTests.System.Windows.Media {
public void ToStringTest ()
{
Matrix m = new Matrix (1, 2, 3, 4, 5, 6);
Assert.AreEqual ("1,2,3,4,5,6", m.ToString());
Assert.AreEqual ("1,2,3,4,5,6", m.ToString(CultureInfo.InvariantCulture));
m = Matrix.Identity;
Assert.AreEqual ("Identity", m.ToString());
}

View File

@@ -0,0 +1,79 @@
using NUnit.Framework;
using System;
using System.Windows.Media.Converters;
using System.Windows.Media;
namespace MonoTests.System.Windows.Media {
[TestFixture]
public class MatrixValueSerializerTest {
const double DELTA = 0.000000001d;
void CheckMatrix (Matrix expected, Matrix actual)
{
Assert.AreEqual (expected.M11, actual.M11, DELTA);
Assert.AreEqual (expected.M12, actual.M12, DELTA);
Assert.AreEqual (expected.M21, actual.M21, DELTA);
Assert.AreEqual (expected.M22, actual.M22, DELTA);
Assert.AreEqual (expected.OffsetX, actual.OffsetX, DELTA);
Assert.AreEqual (expected.OffsetY, actual.OffsetY, DELTA);
}
[Test]
public void CanConvertFromString ()
{
var serializer = new MatrixValueSerializer ();
Assert.IsTrue (serializer.CanConvertFromString ("", null));
}
[Test]
public void CanConvertToString ()
{
var serializer = new MatrixValueSerializer ();
Assert.IsTrue (serializer.CanConvertToString (new Matrix (1, 2, 3, 4, 5 ,6), null));
Assert.IsFalse (serializer.CanConvertToString ("", null));
}
[Test]
public void ConvertFromString ()
{
var serializer = new MatrixValueSerializer ();
object obj = serializer.ConvertFromString ("1, 2, 3, 4, 5 ,6", null);
Assert.AreEqual (typeof (Matrix), obj.GetType ());
CheckMatrix (new Matrix (1, 2, 3, 4, 5, 6), (Matrix)obj);
}
[Test]
public void RoundTripConvert()
{
var serializer = new MatrixValueSerializer ();
var matrix = new Matrix (1.1, 2.2, 3.3, 4.4, 5.5, 6.6);
var obj = serializer.ConvertFromString (serializer.ConvertToString (matrix, null), null);
CheckMatrix (matrix, (Matrix)obj);
}
[Test]
[ExpectedException (typeof (FormatException))]
public void ConvertFromStringShouldThrowExceptionWhenStringHasInvalidFormat ()
{
var serializer = new MatrixValueSerializer ();
serializer.ConvertFromString ("a,b,c,d,e,f", null);
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void ConvertFromStringShouldThrowExceptionWhenStringIsNull ()
{
var serializer = new MatrixValueSerializer ();
serializer.ConvertFromString (null, null);
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void ConvertToStringShouldThrowExceptionWhenInvalidType ()
{
var serializer = new MatrixValueSerializer ();
serializer.ConvertToString (10, null);
}
}
}

View File

@@ -24,6 +24,7 @@
//
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Media;
using NUnit.Framework;
@@ -54,7 +55,6 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
public void ConvertFrom ()
{
Int32RectConverter r = new Int32RectConverter ();
@@ -79,7 +79,6 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
public void ConvertFrom_negative ()
{
Int32RectConverter r = new Int32RectConverter ();
@@ -90,14 +89,13 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
public void ConvertTo ()
{
Int32RectConverter r = new Int32RectConverter ();
Int32Rect rect = new Int32Rect (0, 0, 1, 2);
object o = r.ConvertTo (rect, typeof (string));
object o = r.ConvertTo (null, CultureInfo.InvariantCulture, rect, typeof (string));
Assert.AreEqual (typeof (string), o.GetType());
Assert.AreEqual ("0,0,1,2", (string)o);

View File

@@ -24,6 +24,7 @@
//
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Media;
using NUnit.Framework;
@@ -136,13 +137,12 @@ namespace MonoTests.System.Windows {
public void ToStringTest ()
{
Int32Rect r = new Int32Rect (1, 2, 3, 4);
Assert.AreEqual ("1,2,3,4", r.ToString());
Assert.AreEqual ("1,2,3,4", r.ToString(CultureInfo.InvariantCulture));
Assert.AreEqual ("Empty", Int32Rect.Empty.ToString());
}
[Test]
[Category ("NotWorking")]
public void Parse ()
{
Int32Rect r = Int32Rect.Parse ("1, 2, 3, 4");
@@ -150,7 +150,6 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
public void ParseNegative ()
{
Int32Rect.Parse ("1, 2, -3, -4");

View File

@@ -0,0 +1,69 @@
using System;
using System.Windows;
using System.Windows.Converters;
using NUnit.Framework;
namespace MonoTests.System.Windows {
[TestFixture]
public class Int32RectValueSerializerTest
{
[Test]
public void CanConvertFromString ()
{
var serializer = new Int32RectValueSerializer ();
Assert.IsTrue (serializer.CanConvertFromString ("", null));
}
[Test]
public void CanConvertToString ()
{
var serializer = new Int32RectValueSerializer ();
Assert.IsTrue (serializer.CanConvertToString (new Int32Rect (0, 0, 0, 0), null));
Assert.IsFalse (serializer.CanConvertToString ("", null));
}
[Test]
public void ConvertFromString ()
{
var serializer = new Int32RectValueSerializer ();
object obj = serializer.ConvertFromString ("3,4,5,6", null);
Assert.AreEqual (typeof (Int32Rect), obj.GetType ());
Assert.AreEqual (new Int32Rect (3, 4, 5, 6), obj);
}
[Test]
public void RoundTripConvert()
{
var serializer = new Int32RectValueSerializer ();
var size = new Int32Rect (7, 8, 9, 10);
var obj = serializer.ConvertFromString (serializer.ConvertToString (size, null), null);
Assert.AreEqual (size, obj);
}
[Test]
[ExpectedException (typeof (FormatException))]
public void ConvertFromStringShouldThrowExceptionWhenStringHasInvalidFormat ()
{
var serializer = new Int32RectValueSerializer ();
serializer.ConvertFromString ("a,b,c,d", null);
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void ConvertFromStringShouldThrowExceptionWhenStringIsNull ()
{
var serializer = new Int32RectValueSerializer ();
serializer.ConvertFromString (null, null);
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void ConvertToStringShouldThrowExceptionWhenInvalidType ()
{
var serializer = new Int32RectValueSerializer ();
serializer.ConvertToString (10, null);
}
}
}

View File

@@ -24,6 +24,7 @@
//
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Media;
using NUnit.Framework;
@@ -52,7 +53,6 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
public void ConvertFrom ()
{
PointConverter r = new PointConverter ();
@@ -77,14 +77,13 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
public void ConvertTo ()
{
PointConverter r = new PointConverter ();
Point rect = new Point (1, 2);
object o = r.ConvertTo (rect, typeof (string));
object o = r.ConvertTo (null, CultureInfo.InvariantCulture, rect, typeof (string));
Assert.AreEqual (typeof (string), o.GetType());
Assert.AreEqual ("1,2", (string)o);

View File

@@ -51,20 +51,18 @@ namespace MonoTests.System.Windows {
Assert.IsFalse (p.Equals (new object()));
}
[Test]
[Category ("NotWorking")]
public void getHashCodeTest()
{
Point p1 = new Point(-5, -4);
Point p2 = new Point(5, 4);
Point p3 = new Point(5, 4);
[Test]
public void GetHashCodeTest()
{
Point p1 = new Point(-5, -4);
Point p2 = new Point(5, 4);
Point p3 = new Point(5, 4);
Assert.AreEqual(p2.GetHashCode(), p3.GetHashCode());
Assert.AreEqual(p1.GetHashCode(),p2.GetHashCode());
}
Assert.AreEqual (p2.GetHashCode (), p3.GetHashCode ());
Assert.AreEqual (p1.GetHashCode (),p2.GetHashCode ());
}
[Test]
[Category ("NotWorking")]
public void ToStringTest ()
{
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-us");
@@ -85,7 +83,6 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
public void Parse ()
{
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("fr-fr");

View File

@@ -0,0 +1,69 @@
using System;
using System.Windows;
using System.Windows.Converters;
using NUnit.Framework;
namespace MonoTests.System.Windows {
[TestFixture]
public class PointValueSerializerTest
{
[Test]
public void CanConvertFromString ()
{
var serializer = new PointValueSerializer ();
Assert.IsTrue (serializer.CanConvertFromString ("", null));
}
[Test]
public void CanConvertToString ()
{
var serializer = new PointValueSerializer ();
Assert.IsTrue (serializer.CanConvertToString (new Point (0, 0), null));
Assert.IsFalse (serializer.CanConvertToString ("", null));
}
[Test]
public void ConvertFromString ()
{
var serializer = new PointValueSerializer ();
object obj = serializer.ConvertFromString ("3.14,4.15", null);
Assert.AreEqual (typeof (Point), obj.GetType ());
Assert.AreEqual (new Point (3.14, 4.15), obj);
}
[Test]
public void RoundTripConvert()
{
var serializer = new PointValueSerializer ();
var Point = new Point (1.234, 2.678);
var obj = serializer.ConvertFromString (serializer.ConvertToString (Point, null), null);
Assert.AreEqual (Point, obj);
}
[Test]
[ExpectedException (typeof (FormatException))]
public void ConvertFromStringShouldThrowExceptionWhenStringHasInvalidFormat ()
{
var serializer = new PointValueSerializer ();
serializer.ConvertFromString ("a,b", null);
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void ConvertFromStringShouldThrowExceptionWhenStringIsNull ()
{
var serializer = new PointValueSerializer ();
serializer.ConvertFromString (null, null);
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void ConvertToStringShouldThrowExceptionWhenInvalidType ()
{
var serializer = new PointValueSerializer ();
serializer.ConvertToString (10, null);
}
}
}

View File

@@ -24,6 +24,7 @@
//
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Media;
using NUnit.Framework;
@@ -54,7 +55,6 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
public void ConvertFrom ()
{
RectConverter r = new RectConverter ();
@@ -79,7 +79,6 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
[ExpectedException (typeof (ArgumentException))]
public void ConvertFrom_negative ()
{
@@ -88,14 +87,13 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
public void ConvertTo ()
{
RectConverter r = new RectConverter ();
Rect rect = new Rect (0, 0, 1, 2);
object o = r.ConvertTo (rect, typeof (string));
object o = r.ConvertTo (null, CultureInfo.InvariantCulture, rect, typeof (string));
Assert.AreEqual (typeof (string), o.GetType());
Assert.AreEqual ("0,0,1,2", (string)o);

View File

@@ -327,7 +327,6 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
public void ToString_FormatException ()
{
// This test does not currently work because
@@ -343,7 +342,6 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
public void Parse ()
{
Rect r = Rect.Parse ("1 , 2, 3, 4");
@@ -351,7 +349,6 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
public void Parse2 ()
{
Rect r = Rect.Parse ("1 2 3 4");
@@ -359,7 +356,6 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
public void Parse3 ()
{
Rect r = Rect.Parse (" 1 2 3 4 ");
@@ -367,14 +363,12 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
public void ParseWithBothSeparators ()
{
Rect.Parse ("1.0, 3 2.0, 5.0");
}
[Test]
[Category ("NotWorking")]
[ExpectedException (typeof (ArgumentException))]
public void ParseNegative ()
{
@@ -382,7 +376,6 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
[ExpectedException (typeof (InvalidOperationException))] // "Premature string termination encountered."
public void Parse3Doubles ()
{
@@ -390,7 +383,6 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
[ExpectedException (typeof (FormatException))]
public void ParseInvalidString1 ()
{
@@ -398,7 +390,6 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
[ExpectedException (typeof (InvalidOperationException))]
public void ParseInvalidString3 ()
{
@@ -406,7 +397,6 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
[ExpectedException (typeof (FormatException))]
public void ParseInvalidString4 ()
{
@@ -414,7 +404,6 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
[ExpectedException (typeof (InvalidOperationException))]
public void ParseInvalidString5 ()
{
@@ -422,14 +411,12 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
public void ParseInvalidString6 ()
{
Rect.Parse ("\n1.0, 2.0, 5.0, 2");
}
[Test]
[Category ("NotWorking")]
[ExpectedException (typeof (InvalidOperationException))]
public void ParseInvalidString7 ()
{

View File

@@ -0,0 +1,77 @@
using System;
using System.Windows;
using System.Windows.Converters;
using NUnit.Framework;
namespace MonoTests.System.Windows {
[TestFixture]
public class RectValueSerializerTest
{
[Test]
public void CanConvertFromString ()
{
var serializer = new RectValueSerializer ();
Assert.IsTrue (serializer.CanConvertFromString ("", null));
}
[Test]
public void CanConvertToString ()
{
var serializer = new RectValueSerializer ();
Assert.IsTrue (serializer.CanConvertToString (new Rect (0, 0, 0, 0), null));
Assert.IsFalse (serializer.CanConvertToString ("", null));
}
[Test]
public void ConvertFromString ()
{
var serializer = new RectValueSerializer ();
object obj = serializer.ConvertFromString ("3.14,4.15,5.16,6.17", null);
Assert.AreEqual (typeof (Rect), obj.GetType ());
Assert.AreEqual (new Rect (3.14, 4.15, 5.16, 6.17), obj);
}
[Test]
public void RoundTripConvert()
{
var serializer = new RectValueSerializer ();
var rect = new Rect (1.234, 2.678, 3.123, 4.567);
var obj = serializer.ConvertFromString (serializer.ConvertToString (rect, null), null);
Assert.AreEqual (rect, obj);
}
[Test]
[ExpectedException (typeof (FormatException))]
public void ConvertFromStringShouldThrowExceptionWhenStringHasInvalidFormat ()
{
var serializer = new RectValueSerializer ();
serializer.ConvertFromString ("a,b,c,d", null);
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void ConvertFromStringShouldThrowExceptionWhenStringIsNull ()
{
var serializer = new RectValueSerializer ();
serializer.ConvertFromString (null, null);
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void ConvertToStringShouldThrowExceptionWhenInvalidType ()
{
var serializer = new RectValueSerializer ();
serializer.ConvertToString (10, null);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void ConvertToStringShouldThrowExceptionWhenHeightOrWidthIsNegative ()
{
var serializer = new RectValueSerializer ();
var result = serializer.ConvertFromString ("1,2,-1,-2", null);
}
}
}

View File

@@ -24,6 +24,7 @@
//
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Media;
using NUnit.Framework;
@@ -52,7 +53,6 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
public void ConvertFrom ()
{
SizeConverter r = new SizeConverter ();
@@ -73,7 +73,6 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
[ExpectedException (typeof (ArgumentException))]
public void ConvertFrom_negative ()
{
@@ -82,14 +81,13 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
public void ConvertTo ()
{
SizeConverter r = new SizeConverter ();
Size rect = new Size (1, 2);
object o = r.ConvertTo (rect, typeof (string));
object o = r.ConvertTo (null, CultureInfo.InvariantCulture, rect, typeof (string));
Assert.AreEqual (typeof (string), o.GetType());
Assert.AreEqual ("1,2", (string)o);

View File

@@ -24,6 +24,7 @@
//
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Media;
using NUnit.Framework;
@@ -120,10 +121,32 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
public void Parse ()
public void ParseWithoutWhiteSpaces ()
{
Assert.AreEqual (new Size (1, 2), Size.Parse ("1, 2"));
Assert.AreEqual (new Size (1, 2), Size.Parse ("1,2"));
}
[Test]
public void ParseWithWhiteSpaces ()
{
Assert.AreEqual (new Size (1, 2), Size.Parse (" 1, 2 "));
}
[Test]
public void ParseValueWithFloatingPoint ()
{
Assert.AreEqual (new Size (1.234, 5.678), Size.Parse ("1.234,5.678"));
}
[Test]
public void ParseEmpty ()
{
Assert.AreEqual (Size.Empty, Size.Parse ("Empty"));
}
[Test]
public void ParseEmptyWithWhiteSpaces ()
{
Assert.AreEqual (Size.Empty, Size.Parse (" Empty "));
}
[Test]
@@ -136,7 +159,7 @@ namespace MonoTests.System.Windows {
[Test]
public void ToStringTest ()
{
Assert.AreEqual ("1,2", (new Size (1, 2)).ToString());
Assert.AreEqual ("1,2", (new Size (1, 2)).ToString (CultureInfo.InvariantCulture));
}
[Test]

View File

@@ -0,0 +1,77 @@
using System;
using System.Windows;
using System.Windows.Converters;
using NUnit.Framework;
namespace MonoTests.System.Windows {
[TestFixture]
public class SizeValueSerializerTest
{
[Test]
public void CanConvertFromString ()
{
var serializer = new SizeValueSerializer ();
Assert.IsTrue (serializer.CanConvertFromString ("", null));
}
[Test]
public void CanConvertToString ()
{
var serializer = new SizeValueSerializer ();
Assert.IsTrue (serializer.CanConvertToString (new Size (0, 0), null));
Assert.IsFalse (serializer.CanConvertToString ("", null));
}
[Test]
public void ConvertFromString ()
{
var serializer = new SizeValueSerializer ();
object obj = serializer.ConvertFromString ("3,4", null);
Assert.AreEqual (typeof (Size), obj.GetType ());
Assert.AreEqual (new Size (3, 4), obj);
}
[Test]
public void RoundTripConvert()
{
var serializer = new SizeValueSerializer ();
var size = new Size (1.234, 5.678);
var obj = serializer.ConvertFromString (serializer.ConvertToString (size, null), null);
Assert.AreEqual (size, obj);
}
[Test]
[ExpectedException (typeof (FormatException))]
public void ConvertFromStringShouldThrowExceptionWhenStringHasInvalidFormat ()
{
var serializer = new SizeValueSerializer ();
serializer.ConvertFromString ("a,b", null);
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void ConvertFromStringShouldThrowExceptionWhenStringIsNull ()
{
var serializer = new SizeValueSerializer ();
serializer.ConvertFromString (null, null);
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void ConvertToStringShouldThrowExceptionWhenInvalidType ()
{
var serializer = new SizeValueSerializer ();
serializer.ConvertToString (10, null);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void ConvertToStringShouldThrowExceptionWhenHeightOrWidthIsNegative ()
{
var serializer = new SizeValueSerializer ();
var result = serializer.ConvertFromString ("-1,-4", null);
}
}
}

View File

@@ -24,6 +24,7 @@
//
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Media;
using NUnit.Framework;
@@ -52,7 +53,6 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
public void ConvertFrom ()
{
VectorConverter r = new VectorConverter ();
@@ -77,14 +77,13 @@ namespace MonoTests.System.Windows {
}
[Test]
[Category ("NotWorking")]
public void ConvertTo ()
{
VectorConverter r = new VectorConverter ();
Vector rect = new Vector (1, 2);
object o = r.ConvertTo (rect, typeof (string));
object o = r.ConvertTo (null, CultureInfo.InvariantCulture, rect, typeof (string));
Assert.AreEqual (typeof (string), o.GetType());
Assert.AreEqual ("1,2", (string)o);

View File

@@ -24,6 +24,7 @@
//
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Media;
using NUnit.Framework;
@@ -56,7 +57,7 @@ namespace MonoTests.System.Windows {
public void ToStringTest ()
{
Vector v = new Vector (4, 5);
Assert.AreEqual ("4,5", v.ToString());
Assert.AreEqual ("4,5", v.ToString(CultureInfo.InvariantCulture));
}
[Test]

View File

@@ -0,0 +1,69 @@
using System;
using System.Windows;
using System.Windows.Converters;
using NUnit.Framework;
namespace MonoTests.System.Windows {
[TestFixture]
public class VectorValueSerializerTest
{
[Test]
public void CanConvertFromString ()
{
var serializer = new VectorValueSerializer ();
Assert.IsTrue (serializer.CanConvertFromString ("", null));
}
[Test]
public void CanConvertToString ()
{
var serializer = new VectorValueSerializer ();
Assert.IsTrue (serializer.CanConvertToString (new Vector (0, 0), null));
Assert.IsFalse (serializer.CanConvertToString ("", null));
}
[Test]
public void ConvertFromString ()
{
var serializer = new VectorValueSerializer ();
object obj = serializer.ConvertFromString ("3.14,4.15", null);
Assert.AreEqual (typeof (Vector), obj.GetType ());
Assert.AreEqual (new Vector (3.14, 4.15), obj);
}
[Test]
public void RoundTripConvert()
{
var serializer = new VectorValueSerializer ();
var Vector = new Vector (1.234, 2.678);
var obj = serializer.ConvertFromString (serializer.ConvertToString (Vector, null), null);
Assert.AreEqual (Vector, obj);
}
[Test]
[ExpectedException (typeof (FormatException))]
public void ConvertFromStringShouldThrowExceptionWhenStringHasInvalidFormat ()
{
var serializer = new VectorValueSerializer ();
serializer.ConvertFromString ("a,b", null);
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void ConvertFromStringShouldThrowExceptionWhenStringIsNull ()
{
var serializer = new VectorValueSerializer ();
serializer.ConvertFromString (null, null);
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void ConvertToStringShouldThrowExceptionWhenInvalidType ()
{
var serializer = new VectorValueSerializer ();
serializer.ConvertToString (10, null);
}
}
}