Пример #1
0
        public void ShouldBeAbleToUseProfigurationSetToNameProfigurations()
        {
            DirectoryInfo    dir        = new DirectoryInfo(MethodBase.GetCurrentMethod().Name);
            ProfigurationSet profSet    = new ProfigurationSet(dir);
            string           randomName = "Test_".RandomLetters(4);
            Profiguration    prof       = profSet.Get(randomName);

            Expect.IsNotNull(prof);
            Expect.IsTrue(File.Exists(Path.Combine(dir.FullName, randomName)));
            Expect.IsTrue(File.Exists(Path.Combine(dir.FullName, randomName + ".key")));
        }
Пример #2
0
        public void SettingAProfigurationValueShouldReflectImmediately()
        {
            DirectoryInfo    dir   = new DirectoryInfo(MethodBase.GetCurrentMethod().Name);
            ProfigurationSet set   = new ProfigurationSet(dir);
            string           name  = "Test_".RandomLetters(6);
            string           key   = "Key_".RandomLetters(4);
            string           value = "Value_".RandomLetters(4);

            Profiguration prof = set[name];

            prof.AppSettings[key] = value;

            Expect.AreEqual(value, prof.AppSettings[key], "value didn't get set");
        }
Пример #3
0
        public void ShowProfigurationValues()
        {
            string        filePath = Prompt("Please enter the path to the file", ConsoleColor.Cyan);
            Profiguration prof     = Profiguration.Load(filePath);

            Out("*** AppSettings ***", ConsoleColor.Cyan);
            foreach (string key in prof.AppSettings.Keys)
            {
                OutFormat("{0}={1}\r\n", ConsoleColor.Yellow, key, prof.AppSettings[key]);
            }
            Out();
            Out("*** Connection Strings ***", ConsoleColor.Cyan);
            foreach (string key in prof.ConnectionStrings.Names)
            {
                OutFormat("{0}::{1}={2}", ConsoleColor.Yellow, prof.ConnectionStrings[key].Provider, prof.ConnectionStrings[key].ConnectionString.Key, prof.ConnectionStrings[key].ConnectionString.Value);
            }
        }
Пример #4
0
        public void ShouldBeAbleToSaveAProfigurationProvidingAName()
        {
            DirectoryInfo    dir        = new DirectoryInfo(MethodBase.GetCurrentMethod().Name);
            ProfigurationSet set        = new ProfigurationSet(dir);
            string           randomName = "Test_".RandomLetters(4);
            Profiguration    prof       = new Profiguration();

            prof.AppSettings["test"] = "monkey";

            set.Save(randomName, prof);

            Expect.IsTrue(File.Exists(Path.Combine(dir.FullName, randomName)));
            Expect.IsTrue(File.Exists(Path.Combine(dir.FullName, randomName + ".key")));

            Profiguration verify = set.Get(randomName);

            Expect.AreEqual("monkey", verify.AppSettings["test"]);
        }
Пример #5
0
        public void ShouldBeAbleToUseIndexedProfiguration()
        {
            DirectoryInfo    dir   = new DirectoryInfo(MethodBase.GetCurrentMethod().Name);
            ProfigurationSet set   = new ProfigurationSet(dir);
            string           name  = "Test_".RandomLetters(6);
            string           key   = "Key_".RandomLetters(4);
            string           value = "Value_".RandomLetters(4);

            Profiguration prof = set[name];

            prof.AppSettings[key] = value;

            Expect.AreEqual(value, prof.AppSettings[key], "value didn't get set");

            set.Save();

            ProfigurationSet validate = new ProfigurationSet(dir);

            Expect.AreEqual(value, validate[name].AppSettings[key]);
        }
Пример #6
0
        public void IndexedProfigurationShouldAddName()
        {
            DirectoryInfo dir = new DirectoryInfo(MethodBase.GetCurrentMethod().Name);

            if (dir.Exists)
            {
                dir.Delete(true);
            }

            ProfigurationSet set   = new ProfigurationSet(dir);
            string           name  = "Test_".RandomLetters(6);
            string           key   = "Key_".RandomLetters(4);
            string           value = "Value_".RandomLetters(4);

            Expect.IsTrue(set.ProfigurationNames.Length == 0);

            Profiguration prof = set[name];

            Expect.IsTrue(set.ProfigurationNames.Length == 1);
        }