public void WriteEncryptedConfigurationTest()
        {
            var config = new CustomConfigFileConfiguration();

            config.Initialize();

            // write secure properties
            config.Password            = "******";
            config.AppConnectionString = "server=.;database=unsecured";

            config.Write();

            string text = File.ReadAllText(TestHelpers.GetTestConfigFilePath());

            Console.WriteLine(text);

            // Password and AppSettings  should be encrypted in config file
            Assert.IsTrue(text.Contains(@"<add key=""Password"" value=""ADoCNO6L1HIm8V7TyI4deg=="" />"));
            Assert.IsTrue(text.Contains(@"<add key=""AppConnectionString"" value=""z6+T5mzXbtJBEgWqpQNYbBss0csbtw2b/qdge7PUixE="" />"));

            // now re-read settings into a new object
            var config2 = new CustomConfigFileConfiguration();

            config2.Initialize();

            // check secure properties
            Assert.IsTrue(config.Password == "seekrit2");
            Assert.IsTrue(config.AppConnectionString == "server=.;database=unsecured");
        }
        public void WriteConfigurationTest()
        {
            var config = new CustomConfigFileConfiguration();
            config.Initialize();

            config.MaxDisplayListItems = 12;
            config.DebugMode = DebugModes.DeveloperErrorMessage;
            config.ApplicationName = "Changed";
            config.SendAdminEmailConfirmations = true;

            // secure properties
            config.Password = "******";
            config.AppConnectionString = "server=.;database=unsecured";

            config.Write();

            string text = File.ReadAllText(TestHelpers.GetTestConfigFilePath());
            Console.WriteLine(text);

            Assert.IsTrue(text.Contains(@"<add key=""DebugMode"" value=""DeveloperErrorMessage"" />"));
            Assert.IsTrue(text.Contains(@"<add key=""MaxDisplayListItems"" value=""12"" />"));
            Assert.IsTrue(text.Contains(@"<add key=""SendAdminEmailConfirmations"" value=""True"" />"));

            // Password and AppSettings  should be encrypted in config file
            Assert.IsTrue(text.Contains(@"<add key=""Password"" value=""ADoCNO6L1HIm8V7TyI4deg=="" />"));
            Assert.IsTrue(text.Contains(@"<add key=""AppConnectionString"" value=""z6+T5mzXbtJBEgWqpQNYbBss0csbtw2b/qdge7PUixE="" />"));
        }
示例#3
0
        public void WriteConfigurationTest()
        {
            var config = new CustomConfigFileConfiguration();

            config.Initialize();

            config.MaxDisplayListItems         = 12;
            config.DebugMode                   = DebugModes.DeveloperErrorMessage;
            config.ApplicationName             = "Changed";
            config.SendAdminEmailConfirmations = true;

            // secure properties
            config.Password            = "******";
            config.AppConnectionString = "server=.;database=unsecured";

            config.Write();

            string text = File.ReadAllText(TestHelpers.GetTestConfigFilePath());

            Console.WriteLine(text);

            Assert.IsTrue(text.Contains(@"<add key=""DebugMode"" value=""DeveloperErrorMessage"" />"));
            Assert.IsTrue(text.Contains(@"<add key=""MaxDisplayListItems"" value=""12"" />"));
            Assert.IsTrue(text.Contains(@"<add key=""SendAdminEmailConfirmations"" value=""True"" />"));

            // Password and AppSettings  should be encrypted in config file
            Assert.IsTrue(text.Contains(@"<add key=""Password"" value=""ADoCNO6L1HIm8V7TyI4deg=="" />"));
            Assert.IsTrue(text.Contains(@"<add key=""AppConnectionString"" value=""z6+T5mzXbtJBEgWqpQNYbBss0csbtw2b/qdge7PUixE="" />"));
        }
        public void WriteEncryptedConfigurationTest()
        {
            var config = new CustomConfigFileConfiguration();
            config.Initialize();

            // write secure properties
            config.Password = "******";
            config.AppConnectionString = "server=.;database=unsecured";

            config.Write();
            
            string text = File.ReadAllText(TestHelpers.GetTestConfigFilePath());
            Console.WriteLine(text);
            
            // Password and AppSettings  should be encrypted in config file
            Assert.IsTrue(text.Contains(@"<add key=""Password"" value=""ADoCNO6L1HIm8V7TyI4deg=="" />"));
            Assert.IsTrue(text.Contains(@"<add key=""AppConnectionString"" value=""z6+T5mzXbtJBEgWqpQNYbBss0csbtw2b/qdge7PUixE="" />"));
            
            // now re-read settings into a new object
            var config2 = new CustomConfigFileConfiguration();
            config2.Initialize();
            
            // check secure properties
            Assert.IsTrue(config.Password == "seekrit2");
            Assert.IsTrue(config.AppConnectionString == "server=.;database=unsecured");
        }
        public void WriteConfigurationTest()
        {
            File.Delete(TestHelpers.GetTestConfigFilePath());

            var config = new CustomConfigFileConfiguration();
            config.Initialize();
            
            config.MaxDisplayListItems = 12;
            config.DebugMode = DebugModes.DeveloperErrorMessage;
            config.ApplicationName = "Changed";
            config.SendAdminEmailConfirmations = true;

            // secure properties
            config.Password = "******";
            config.AppConnectionString = "server=.;database=unsecured";

            // Complex Types
            config.License.Company = "Updated Company";
            config.ServerList[0] = "UpdatedServerName";

            config.License.Name = "Rick";
            config.License.Company = "West Wind 2";
            config.License.LicenseKey = "RickWestWind2-51231223";

            config.Write();

            config = null;
            config = new CustomConfigFileConfiguration();
            config.Initialize();

            Console.WriteLine(config.License.LicenseKey);
            Assert.IsTrue(config.License.LicenseKey == "RickWestWind2-51231223");
            
            
            string text = File.ReadAllText(TestHelpers.GetTestConfigFilePath());
            Console.WriteLine(text);

            Assert.IsTrue(text.Contains(@"<add key=""DebugMode"" value=""DeveloperErrorMessage"" />"));
            Assert.IsTrue(text.Contains(@"<add key=""MaxDisplayListItems"" value=""12"" />"));
            Assert.IsTrue(text.Contains(@"<add key=""SendAdminEmailConfirmations"" value=""True"" />"));

            // Password and AppSettings  should be encrypted in config file
            Assert.IsTrue(text.Contains(@"<add key=""Password"" value=""ADoCNO6L1HIm8V7TyI4deg=="" />"));
            Assert.IsTrue(text.Contains(@"<add key=""AppConnectionString"" value=""z6+T5mzXbtJBEgWqpQNYbBss0csbtw2b/qdge7PUixE="" />"));

            // Complex Value
            Assert.IsTrue(text.Contains(@"West Wind 2"));

            // List values
            Assert.IsTrue(text.Contains(@"<add key=""ServerList1"""));
            Assert.IsTrue(text.Contains(@"UpdatedServerName"));



        }
示例#6
0
        public void WriteConfigurationTest()
        {
            File.Delete(TestHelpers.GetTestConfigFilePath());

            var config = new CustomConfigFileConfiguration();
            config.Initialize();
            
            config.MaxDisplayListItems = 12;
            config.DebugMode = DebugModes.DeveloperErrorMessage;
            config.ApplicationName = "Changed";
            config.SendAdminEmailConfirmations = true;

            // secure properties
            config.Password = "******";
            config.AppConnectionString = "server=.;database=unsecured";

            // Complex Types
            config.License.Company = "Updated Company";
            config.ServerList[0] = "UpdatedServerName";

            config.License.Name = "Rick";
            config.License.Company = "West Wind 2";
            config.License.LicenseKey = "RickWestWind2-51231223";

            config.Write();

            config = null;
            config = new CustomConfigFileConfiguration();
            config.Initialize();

            Console.WriteLine(config.License.LicenseKey);
            Assert.IsTrue(config.License.LicenseKey == "RickWestWind2-51231223");
            
            
            string text = File.ReadAllText(TestHelpers.GetTestConfigFilePath());
            Console.WriteLine(text);

            Assert.IsTrue(text.Contains(@"<add key=""DebugMode"" value=""DeveloperErrorMessage"" />"));
            Assert.IsTrue(text.Contains(@"<add key=""MaxDisplayListItems"" value=""12"" />"));
            Assert.IsTrue(text.Contains(@"<add key=""SendAdminEmailConfirmations"" value=""True"" />"));

            // Password and AppSettings  should be encrypted in config file
            Assert.IsTrue(text.Contains(@"<add key=""Password"" value=""ADoCNO6L1HIm8V7TyI4deg=="" />"));
            Assert.IsTrue(text.Contains(@"<add key=""AppConnectionString"" value=""z6+T5mzXbtJBEgWqpQNYbBss0csbtw2b/qdge7PUixE="" />"));

            // Complex Value
            Assert.IsTrue(text.Contains(@"West Wind 2"));

            // List values
            Assert.IsTrue(text.Contains(@"<add key=""ServerList1"""));
            Assert.IsTrue(text.Contains(@"UpdatedServerName"));



        }
        public void DefaultConstructorInstanceTest()
        {
            var config = new CustomConfigFileConfiguration();
            config.Initialize();

            Assert.IsNotNull(config);
            Assert.IsFalse(string.IsNullOrEmpty(config.ApplicationName));

            string text = File.ReadAllText(TestHelpers.GetTestConfigFilePath());
            Assert.IsTrue(text.Contains(@"<add key=""MaxDisplayListItems"" value=""15"" />"));
            Console.WriteLine(text);
        }
示例#8
0
        public void DefaultConstructorInstanceTest()
        {
            var config = new CustomConfigFileConfiguration();
            config.Initialize();

            Assert.IsNotNull(config);
            Assert.IsFalse(string.IsNullOrEmpty(config.ApplicationName));
            
            string text = File.ReadAllText(TestHelpers.GetTestConfigFilePath());
            Assert.IsTrue(text.Contains(@"<add key=""MaxDisplayListItems"" value=""15"" />"));
            Console.WriteLine(text);          
        }
        public void CustomFileLocationInstanceTest()
        {
            var configFile = Path.Combine(Path.GetTempPath(), "testconfig.config");

            var config = new CustomConfigFileConfiguration();

            config.ConfigFile = configFile; // custom property to pass in the path
            config.Initialize();

            Assert.IsNotNull(config);
            Assert.IsFalse(string.IsNullOrEmpty(config.ApplicationName));

            string text = File.ReadAllText(configFile); // TestHelpers.GetTestConfigFilePath());

            Assert.IsTrue(text.Contains(@"<add key=""MaxDisplayListItems"" value=""15"" />"));
            Console.WriteLine(text);

            File.Delete(configFile);
        }