public void ConvertFrom()
 {
     CredentialConverter cc = new CredentialConverter();
     object credential = cc.ConvertFrom(@"Spring\bbaia:sprnet");
     Assert.IsNotNull(credential);
     Assert.IsTrue(credential is NetworkCredential);
     
     NetworkCredential nc = (NetworkCredential)credential;
     Assert.AreEqual("Spring", nc.Domain);
     Assert.AreEqual("bbaia", nc.UserName);
     Assert.AreEqual("sprnet", nc.Password);
 }
Example #2
0
        public void ConvertFromStringWithoutDomain()
        {
            CredentialConverter cc = new CredentialConverter();
            object credential      = cc.ConvertFrom(@"bbaia:sprnet");

            Assert.IsNotNull(credential);
            Assert.IsTrue(credential is NetworkCredential);

            NetworkCredential nc = (NetworkCredential)credential;

            Assert.AreEqual(string.Empty, nc.Domain);
            Assert.AreEqual("bbaia", nc.UserName);
            Assert.AreEqual("sprnet", nc.Password);
        }
Example #3
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(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();

                // register user-defined type converters
            }
        }
        /// <summary>
        /// Registers standard and configured type converters.
        /// </summary>
        static TypeConverterRegistry()
        {
            lock (converters.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 ConvertFromMalformedString()
 {
     CredentialConverter cc = new CredentialConverter();
     Assert.Throws<ArgumentException>(() => cc.ConvertFrom(@"Spring:bbaia\sprnet"));
 }
        public void ConvertFromNullReference()
        {
            CredentialConverter cc = new CredentialConverter();

            cc.ConvertFrom(null);
        }
Example #7
0
        public void ConvertFromEmptyString()
        {
            CredentialConverter cc = new CredentialConverter();

            Assert.Throws <ArgumentException>(() => cc.ConvertFrom(string.Empty));
        }
Example #8
0
        public void ConvertFromMalformedString()
        {
            CredentialConverter cc = new CredentialConverter();

            Assert.Throws <ArgumentException>(() => cc.ConvertFrom(@"Spring:bbaia\sprnet"));
        }
 public void ConvertFromEmptyString()
 {
     CredentialConverter cc = new CredentialConverter();
     cc.ConvertFrom(string.Empty);
 }
 public void ConvertFromStringWithIncorrectPassword()
 {
     CredentialConverter cc = new CredentialConverter();
     object credential      = cc.ConvertFrom(@"\bbaia:");
 }
        public void ConvertFromStringWithUsernameOnly()
        {
            CredentialConverter cc = new CredentialConverter();
            object credential = cc.ConvertFrom(@"bbaia");
            Assert.IsNotNull(credential);
            Assert.IsTrue(credential is NetworkCredential);

            NetworkCredential nc = (NetworkCredential)credential;
            Assert.AreEqual(string.Empty, nc.Domain);
            Assert.AreEqual("bbaia", nc.UserName);
            Assert.AreEqual(string.Empty, nc.Password);
        }
 public void ConvertFromNonSupportedOptionBails()
 {
     CredentialConverter cc = new CredentialConverter();
     cc.ConvertFrom(12);
 }
 public void ConvertFromEmptyString()
 {
     CredentialConverter cc = new CredentialConverter();
     Assert.Throws<ArgumentException>(() => cc.ConvertFrom(string.Empty));
 }
 public void ConvertFromStringWithIncorrectDomain()
 {
     CredentialConverter cc = new CredentialConverter();
     object credential = cc.ConvertFrom(@"\bbaia:sprnet");
 }
 public void ConvertFromNonSupportedOptionBails()
 {
     CredentialConverter cc = new CredentialConverter();
     Assert.Throws<NotSupportedException>(() => cc.ConvertFrom(12));
 }
 public void ConvertFromNullReference()
 {
     CredentialConverter cc = new CredentialConverter();
     Assert.Throws<NotSupportedException>(() => cc.ConvertFrom(null));
 }
 public void ConvertFromMalformedString()
 {
     CredentialConverter cc = new CredentialConverter();
     object credential      = cc.ConvertFrom(@"Spring:bbaia\sprnet");
 }
        public void ConvertFromEmptyString()
        {
            CredentialConverter cc = new CredentialConverter();

            cc.ConvertFrom(string.Empty);
        }
        public void ConvertFromNonSupportedOptionBails()
        {
            CredentialConverter cc = new CredentialConverter();

            cc.ConvertFrom(12);
        }
 public void ConvertFromStringWithIncorrectPassword()
 {
     CredentialConverter cc = new CredentialConverter();
     object credential = cc.ConvertFrom(@"\bbaia:");
 }
 public void ConvertFromStringWithIncorrectDomain()
 {
     CredentialConverter cc = new CredentialConverter();
     Assert.Throws<ArgumentException>(() => cc.ConvertFrom(@"\bbaia:sprnet"));
 }
 public void ConvertFromNullReference()
 {
     CredentialConverter cc = new CredentialConverter();
     cc.ConvertFrom(null);
 }
Example #23
0
        public void ConvertFromStringWithIncorrectPassword()
        {
            CredentialConverter cc = new CredentialConverter();

            Assert.Throws <ArgumentException>(() => cc.ConvertFrom(@"\bbaia:"));
        }
Example #24
0
        public void ConvertFromNullReference()
        {
            CredentialConverter cc = new CredentialConverter();

            Assert.Throws <NotSupportedException>(() => cc.ConvertFrom(null));
        }
Example #25
0
        public void ConvertFromNonSupportedOptionBails()
        {
            CredentialConverter cc = new CredentialConverter();

            Assert.Throws <NotSupportedException>(() => cc.ConvertFrom(12));
        }
 public void ConvertFromMalformedString()
 {
     CredentialConverter cc = new CredentialConverter();
     object credential = cc.ConvertFrom(@"Spring:bbaia\sprnet");
 }
 public void ConvertFromStringWithIncorrectDomain()
 {
     CredentialConverter cc = new CredentialConverter();
     object credential      = cc.ConvertFrom(@"\bbaia:sprnet");
 }