public void CanConvertFrom() { UriConverter vrt = new UriConverter(); Assert.IsTrue(vrt.CanConvertFrom(typeof(string)), "Conversion from a string instance must be supported."); Assert.IsFalse(vrt.CanConvertFrom(typeof(int))); }
public void ConvertFrom() { UriConverter vrt = new UriConverter(); object actual = vrt.ConvertFrom("svn://localhost/Spring/trunk/"); Assert.IsNotNull(actual); Assert.AreEqual(typeof(System.Uri), actual.GetType()); }
public void ConvertFromMalformedUriBails() { try { UriConverter vrt = new UriConverter(); object actual = vrt.ConvertFrom("$TheAngelGang"); } catch (Exception ex) { // check that the inner exception was doe to the malformed URL Assert.IsTrue(ex.InnerException is UriFormatException); } }
/// <summary> /// Registers standard and configured type converters. /// </summary> static TypeConverterRegistry() { lock (syncRoot) { converters[typeof(string[])] = new StringArrayConverter(); converters[typeof(Type)] = new RuntimeTypeConverter(); //converters[typeof(Color)] = new RGBColorConverter(); converters[typeof(Uri)] = new UriConverter(); converters[typeof(FileInfo)] = new FileInfoConverter(); converters[typeof(Stream)] = new StreamConverter(); converters[typeof(NameValueCollection)] = new NameValueConverter(); converters[typeof(ResourceManager)] = new ResourceManagerConverter(); converters[typeof(Regex)] = new RegexConverter(); converters[typeof(TimeSpan)] = new TimeSpanConverter(); converters[typeof(ICredentials)] = new CredentialConverter(); converters[typeof(NetworkCredential)] = new CredentialConverter(); //converters[typeof(RegistryKey)] = new RegistryKeyConverter(); // register user-defined type converters ConfigurationUtils.GetSection(TypeConvertersSectionName); } }
public void ConvertFromNonSupportedOptionBails() { UriConverter vrt = new UriConverter(); Assert.Throws <NotSupportedException>(() => vrt.ConvertFrom(12)); }
public void ConvertFromNullReference() { UriConverter vrt = new UriConverter(); Assert.Throws <NotSupportedException>(() => vrt.ConvertFrom(null)); }