Esempio n. 1
0
        public void GetConnectionString_EitherOfTwoSettings()
        {
            NameValueCollection config = new NameValueCollection();

            config.Add("connectionString", "DummyString");
            config.Add(settingsClassName, "DummyClass");
            config.Add(settingsMethodName, "DummyMethodName");

            Exception ex = Assert.Throws <ConfigurationErrorsException>(() => ProviderConfiguration.GetConnectionString(config));

            Assert.Contains("Either use the combination of parameters \"settingsClassName\" and \"settingsMethodName\" to provide the value of connection string or use the parameter \"connectionString\" but not both.", ex.Message);

            NameValueCollection config2 = new NameValueCollection();

            config2.Add("connectionString", "DummyString");
            config2.Add(settingsClassName, "DummyClass");

            Exception ex2 = Assert.Throws <ConfigurationErrorsException>(() => ProviderConfiguration.GetConnectionString(config2));

            Assert.Contains("Either use the combination of parameters \"settingsClassName\" and \"settingsMethodName\" to provide the value of connection string or use the parameter \"connectionString\" but not both.", ex2.Message);

            NameValueCollection config3 = new NameValueCollection();

            config3.Add("connectionString", "DummyString");
            config3.Add(settingsMethodName, "DummyMethodName");

            Exception ex3 = Assert.Throws <ConfigurationErrorsException>(() => ProviderConfiguration.GetConnectionString(config3));

            Assert.Contains("Either use the combination of parameters \"settingsClassName\" and \"settingsMethodName\" to provide the value of connection string or use the parameter \"connectionString\" but not both.", ex3.Message);
        }
Esempio n. 2
0
        public void GetConnectionString_Valid()
        {
            NameValueCollection config = new NameValueCollection();

            config.Add(settingsClassName, typeof(SettingsProvider).AssemblyQualifiedName);
            config.Add(settingsMethodName, "GetSettings");
            Assert.Equal("localhost:6380", ProviderConfiguration.GetConnectionString(config));
        }
Esempio n. 3
0
        public void GetConnectionString_MethodWithIntReturn()
        {
            NameValueCollection config = new NameValueCollection();

            config.Add(settingsClassName, typeof(SettingsProvider).AssemblyQualifiedName);
            config.Add(settingsMethodName, "GetSettingsWithIntReturn");

            Exception ex = Assert.Throws <MissingMethodException>(() => ProviderConfiguration.GetConnectionString(config));

            Assert.Contains("GetSettingsWithIntReturn", ex.Message);
        }
Esempio n. 4
0
        public void GetConnectionString_ClassNameButNotAssemblyQualified()
        {
            NameValueCollection config = new NameValueCollection();

            config.Add(settingsClassName, "Microsoft.Web.Redis.Tests.ProviderConfigurationTests");
            config.Add(settingsMethodName, "DummyMethodName");

            Exception ex = Assert.Throws <MissingMethodException>(() => ProviderConfiguration.GetConnectionString(config));

            Assert.Contains("DummyMethodName", ex.Message);
        }
Esempio n. 5
0
        public void GetConnectionString_WrongClassName()
        {
            NameValueCollection config = new NameValueCollection();

            config.Add(settingsClassName, "DummyClass");
            config.Add(settingsMethodName, "DummyMethodName");

            Exception ex = Assert.Throws <TypeLoadException>(() => ProviderConfiguration.GetConnectionString(config));

            Assert.Contains("The specified class 'DummyClass' could not be loaded", ex.Message);
        }