public void ConvertToString() { RuntimeTypeConverter cnv = new RuntimeTypeConverter (); object foo = cnv.ConvertTo (typeof (string), typeof (string)); Assert.IsNotNull (foo); Assert.AreEqual (typeof (string).AssemblyQualifiedName, foo); }
public void ConvertFromString() { RuntimeTypeConverter cnv = new RuntimeTypeConverter (); object foo = cnv.ConvertFrom ("System.String"); Assert.IsNotNull (foo); Assert.AreEqual (this.GetType().GetType().FullName, foo.GetType ().FullName); }
/// <summary> /// Registers standard and configured type converters. /// </summary> static TypeConverterRegistry() { lock (_syncRoot) { _converters[typeof(string[])] = new StringArrayConverter(); _converters[typeof(Type)] = new RuntimeTypeConverter(); _converters[typeof(Uri)] = new UriConverter(); _converters[typeof(FileInfo)] = new FileInfoConverter(); _converters[typeof(NameValueCollection)] = new NameValueConverter(); _converters[typeof(Regex)] = new RegexConverter(); _converters[typeof(TimeSpan)] = new TimeSpanConverter(); } }
public void ConvertToStringFromNonSupportedType() { RuntimeTypeConverter cnv = new RuntimeTypeConverter (); object foo = cnv.ConvertTo (typeof (string), GetType ()); }
public void ConvertFromNonSupportedType() { RuntimeTypeConverter cnv = new RuntimeTypeConverter (); object foo = cnv.ConvertFrom (12); }
public void CanConvertTo() { RuntimeTypeConverter cnv = new RuntimeTypeConverter (); Assert.IsTrue (cnv.CanConvertTo (typeof (Type)), "Mmm... I can't convert to a Type at all."); Assert.IsFalse (cnv.CanConvertTo (typeof (void)), "Mmm... managed to convert to a Type from a bad type. Boing!"); }
public void CanConvertFrom() { RuntimeTypeConverter cnv = new RuntimeTypeConverter (); Assert.IsTrue (cnv.CanConvertFrom (typeof (string)), "Mmm... I can't convert from a string to a Type."); Assert.IsFalse (cnv.CanConvertFrom (GetType ()), "Mmm... managed to convert to a Type from a Type of this test. Boing!"); }