コード例 #1
0
        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)));
        }
コード例 #2
0
        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());
        }
コード例 #3
0
 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);
     }
 }
コード例 #4
0
        /// <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);
            }
        }
コード例 #5
0
        public void ConvertFromNonSupportedOptionBails()
        {
            UriConverter vrt = new UriConverter();

            Assert.Throws <NotSupportedException>(() => vrt.ConvertFrom(12));
        }
コード例 #6
0
        public void ConvertFromNullReference()
        {
            UriConverter vrt = new UriConverter();

            Assert.Throws <NotSupportedException>(() => vrt.ConvertFrom(null));
        }