public void TestPointTypeConverter() { var converter = new PointTypeConverter(); Assert.True(converter.CanConvertFrom(typeof(string))); Assert.AreEqual(new Point(1, 2), converter.ConvertFromInvariantString("1,2")); Assert.AreEqual(new Point(1, 2), converter.ConvertFromInvariantString("1, 2")); Assert.AreEqual(new Point(1, 2), converter.ConvertFromInvariantString(" 1 , 2 ")); Assert.AreEqual(new Point(1.1, 2), converter.ConvertFromInvariantString("1.1,2")); Assert.Throws <InvalidOperationException> (() => converter.ConvertFromInvariantString("")); }
public override bool CanConvertFrom(Type sourceType) { return(_converter.CanConvertFrom(sourceType)); }
public void TestPointTypeConverter () { var converter = new PointTypeConverter (); Assert.True (converter.CanConvertFrom (typeof(string))); Assert.AreEqual (new Point (1, 2), converter.ConvertFromInvariantString ("1,2")); Assert.AreEqual (new Point (1, 2), converter.ConvertFromInvariantString ("1, 2")); Assert.AreEqual (new Point (1, 2), converter.ConvertFromInvariantString (" 1 , 2 ")); Assert.AreEqual (new Point (1.1, 2), converter.ConvertFromInvariantString ("1.1,2")); Assert.Throws<InvalidOperationException> (()=>converter.ConvertFromInvariantString ("")); }