protected void LoadConfigFile()
 {
     string dir = Path.GetDirectoryName(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
     DirectoryInfo di = new DirectoryInfo(dir);
     bool found = false;
     while (di != null && di.Parent != null && di != di.Parent)
     {
         string fn = Path.Combine(di.FullName, ConfigFile);
         log.Debug("Looking for config in {0}", fn);
         if (File.Exists(fn))
         {
             log.Debug("Loading config from {0}", fn);
             _props = new PropertyFileVariableSource();
             _props.Location = new Spring.Core.IO.FileSystemResource(fn);
             SetInternal("configfile", fn);
             SetInternal("configdir", di.FullName);
             found = true;
             break;
         }
         else
         {
             di = di.Parent;
         }
     }
     if (!found)
     {
         log.Warn("Config file not found: {0}", ConfigFile);
     }
 }
        public void TestVariablesResolutionWithSingleLocation()
        {
            PropertyFileVariableSource vs = new PropertyFileVariableSource();
            vs.Location =
                new AssemblyResource(
                    "assembly://Spring.Core.Tests/Spring.Data.Spring.Objects.Factory.Config/one.properties");

            // existing vars
            Assert.AreEqual("Aleks Seovic", vs.ResolveVariable("name"));
            Assert.AreEqual("32", vs.ResolveVariable("age"));

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

            vs.Location =
                new AssemblyResource(
                    "assembly://Spring.Core.Tests/Spring.Data.Spring.Objects.Factory.Config/one.properties");

            // existing vars
            Assert.AreEqual("Aleks Seovic", vs.ResolveVariable("name"));
            Assert.AreEqual("32", vs.ResolveVariable("age"));

            // non-existant variable
            Assert.IsNull(vs.ResolveVariable("dummy"));
        }
        public void TestMissingResourceLocation()
        {
            PropertyFileVariableSource vs = new PropertyFileVariableSource();
            vs.IgnoreMissingResources = true;
            vs.Locations = new IResource[]
                               {
                                   new AssemblyResource(
                                       "assembly://Spring.Core.Tests/Spring.Data.Spring.Objects.Factory.Config/non-existent.properties")
                                   ,
                                   new AssemblyResource(
                                       "assembly://Spring.Core.Tests/Spring.Data.Spring.Objects.Factory.Config/one.properties")
                                   ,
                               };

            // existing vars
            Assert.AreEqual("Aleks Seovic", vs.ResolveVariable("name"));
            Assert.AreEqual("32", vs.ResolveVariable("age"));
        }
        public void TestMissingResourceLocation()
        {
            PropertyFileVariableSource vs = new PropertyFileVariableSource();

            vs.IgnoreMissingResources = true;
            vs.Locations = new IResource[]
            {
                new AssemblyResource(
                    "assembly://Spring.Core.Tests/Spring.Data.Spring.Objects.Factory.Config/non-existent.properties")
                ,
                new AssemblyResource(
                    "assembly://Spring.Core.Tests/Spring.Data.Spring.Objects.Factory.Config/one.properties")
                ,
            };

            // existing vars
            Assert.AreEqual("Aleks Seovic", vs.ResolveVariable("name"));
            Assert.AreEqual("32", vs.ResolveVariable("age"));
        }
        public void TestVariablesResolutionWithTwoLocations()
        {
            PropertyFileVariableSource vs = new PropertyFileVariableSource();
            vs.Locations = new IResource[]
                               {
                                   new AssemblyResource(
                                       "assembly://Spring.Core.Tests/Spring.Data.Spring.Objects.Factory.Config/one.properties")
                                   ,
                                   new AssemblyResource(
                                       "assembly://Spring.Core.Tests/Spring.Data.Spring.Objects.Factory.Config/two.properties")
                               };

            // existing vars
            Assert.AreEqual("Aleksandar Seovic", vs.ResolveVariable("name")); // should be overriden by the second file
            Assert.AreEqual("32", vs.ResolveVariable("age"));
            Assert.AreEqual("Marija,Ana,Nadja", vs.ResolveVariable("family"));

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

            vs.Locations = new IResource[]
            {
                new AssemblyResource(
                    "assembly://Spring.Core.Tests/Spring.Data.Spring.Objects.Factory.Config/one.properties")
                ,
                new AssemblyResource(
                    "assembly://Spring.Core.Tests/Spring.Data.Spring.Objects.Factory.Config/two.properties")
            };

            // existing vars
            Assert.AreEqual("Aleksandar Seovic", vs.ResolveVariable("name")); // should be overriden by the second file
            Assert.AreEqual("32", vs.ResolveVariable("age"));
            Assert.AreEqual("Marija,Ana,Nadja", vs.ResolveVariable("family"));

            // non-existant variable
            Assert.IsNull(vs.ResolveVariable("dummy"));
        }