public void SunnyDay()
        {
            StaticApplicationContext ac = new StaticApplicationContext();

            MutablePropertyValues pvs = new MutablePropertyValues();

            pvs.Add("age", "${maxResults}");
            pvs.Add("name", "${name}");
            ac.RegisterSingleton("tb1", typeof(TestObject), pvs);

            IList variableSources             = new ArrayList();
            CommandLineArgsVariableSource vs1 = new CommandLineArgsVariableSource(
                new string[] { "program.exe", "file.txt", "/name:Aleks Seovic", "/framework:Spring.NET" });

            variableSources.Add(vs1);

            ConfigSectionVariableSource vs2 = new ConfigSectionVariableSource();

            vs2.SectionName = "DaoConfiguration";
            variableSources.Add(vs2);


            pvs = new MutablePropertyValues();
            pvs.Add("VariableSources", variableSources);

            ac.RegisterSingleton("configurer", typeof(VariablePlaceholderConfigurer), pvs);
            ac.Refresh();

            TestObject tb1 = (TestObject)ac.GetObject("tb1");

            Assert.AreEqual(1000, tb1.Age);
            Assert.AreEqual("Aleks Seovic", tb1.Name);
        }
 public void TestVariableResolutionFromApplicationSettingsSchema()
 {
     ConfigSectionVariableSource vs = new ConfigSectionVariableSource();
     vs.SectionName = "applicationSettings/MyApp.Properties.Settings";
     Assert.AreEqual("1000", vs.ResolveVariable("maxResults"));
     Assert.AreEqual(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\Northwind.mdb;User ID=Admin;Password=;",
         vs.ResolveVariable("connection.string"));
 }
Exemple #3
0
        public void TestVariableResolutionFromApplicationSettingsSchema()
        {
            ConfigSectionVariableSource vs = new ConfigSectionVariableSource();

            vs.SectionName = "applicationSettings/MyApp.Properties.Settings";
            Assert.AreEqual("1000", vs.ResolveVariable("maxResults"));
            Assert.AreEqual(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\Northwind.mdb;User ID=Admin;Password=;",
                            vs.ResolveVariable("connection.string"));
        }
        public void TestVariablesResolutionWithSingleSection()
        {
            ConfigSectionVariableSource vs = new ConfigSectionVariableSource();
            vs.SectionName = "DaoConfiguration";

            // existing vars
            Assert.AreEqual("1000", vs.ResolveVariable("maxResults"));
            Assert.AreEqual("1000", vs.ResolveVariable("MAXResults"));

            // non-existant variable
            Assert.IsNull(vs.ResolveVariable("dummy"));
        }
Exemple #5
0
        public void TestVariablesResolutionWithSingleSection()
        {
            ConfigSectionVariableSource vs = new ConfigSectionVariableSource();

            vs.SectionName = "DaoConfiguration";

            // existing vars
            Assert.AreEqual("1000", vs.ResolveVariable("maxResults"));
            Assert.AreEqual("1000", vs.ResolveVariable("MAXResults"));

            // non-existant variable
            Assert.IsNull(vs.ResolveVariable("dummy"));
        }
        public void TestVariablesResolutionWithTwoSections()
        {
            ConfigSectionVariableSource vs = new ConfigSectionVariableSource();
            vs.SectionNames = new string[] { "DaoConfiguration", "DatabaseConfiguration" };

            // existing vars
            Assert.AreEqual("1000", vs.ResolveVariable("maxResults"));
            Assert.AreEqual("1000", vs.ResolveVariable("MAXResults"));
            Assert.AreEqual(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\Northwind.mdb;User ID=Admin;Password=;",
                            vs.ResolveVariable("connection.string"));
            Assert.AreEqual(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\Northwind.mdb;User ID=Admin;Password=;",
                            vs.ResolveVariable("Connection.String"));

            // non-existant variable
            Assert.IsNull(vs.ResolveVariable("dummy"));
        }
Exemple #7
0
        public void TestVariablesResolutionWithTwoSections()
        {
            ConfigSectionVariableSource vs = new ConfigSectionVariableSource();

            vs.SectionNames = new string[] { "DaoConfiguration", "DatabaseConfiguration" };

            // existing vars
            Assert.AreEqual("1000", vs.ResolveVariable("maxResults"));
            Assert.AreEqual("1000", vs.ResolveVariable("MAXResults"));
            Assert.AreEqual(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\Northwind.mdb;User ID=Admin;Password=;",
                            vs.ResolveVariable("connection.string"));
            Assert.AreEqual(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\Northwind.mdb;User ID=Admin;Password=;",
                            vs.ResolveVariable("Connection.String"));

            // non-existant variable
            Assert.IsNull(vs.ResolveVariable("dummy"));
        }
        public void SunnyDay()
        {
            StaticApplicationContext ac = new StaticApplicationContext();

            MutablePropertyValues pvs = new MutablePropertyValues();
            pvs.Add("age", "${maxResults}");
            pvs.Add("name", "${name}");
            ac.RegisterSingleton("tb1", typeof(TestObject), pvs);

            IList variableSources = new ArrayList();
            CommandLineArgsVariableSource vs1 = new CommandLineArgsVariableSource(
                new string[] { "program.exe", "file.txt", "/name:Aleks Seovic", "/framework:Spring.NET" });
            variableSources.Add(vs1);

            ConfigSectionVariableSource vs2 = new ConfigSectionVariableSource();
            vs2.SectionName = "DaoConfiguration";
            variableSources.Add(vs2);


            pvs = new MutablePropertyValues();
            pvs.Add("VariableSources", variableSources);

            ac.RegisterSingleton("configurer", typeof(VariablePlaceholderConfigurer), pvs);
            ac.Refresh();

            TestObject tb1 = (TestObject)ac.GetObject("tb1");
            Assert.AreEqual(1000, tb1.Age);
            Assert.AreEqual("Aleks Seovic", tb1.Name);

        }