private static void InsertSetting1(SQLiteCommand command)
        {
            command.CommandText = ResourceReader.ReadEmbeddedResource <ConfigurationTest_SQLite>("Resources.InsertSetting1.sql");
            command.Parameters.Clear();
            command.Parameters.Add("@Name", DbType.String, 50);
            command.Parameters.Add("@Value", DbType.String, -1);

            foreach (var testSetting in TestSettingFactory.CreateTestSettings1())
            {
                command.Parameters["@Name"].Value  = testSetting.Name;
                command.Parameters["@Value"].Value = testSetting.Value.Recode(Encoding.UTF8, Encoding.Default);
                command.ExecuteNonQuery();
            }
        }
        private static void InsertSetting1(SqlCommand sqlCommand)
        {
            sqlCommand.CommandText = ResourceReader.ReadEmbeddedResource <ConfigurationTest_SqlServer>("Resources.InsertSetting1.sql");
            sqlCommand.Parameters.Clear();
            sqlCommand.Parameters.Add("@Name", SqlDbType.NVarChar, 50);
            sqlCommand.Parameters.Add("@Value", SqlDbType.NVarChar, -1);

            foreach (var testSetting in TestSettingFactory.CreateTestSettings1())
            {
                sqlCommand.Parameters["@Name"].Value  = testSetting.Name;
                sqlCommand.Parameters["@Value"].Value = testSetting.Value;
                sqlCommand.ExecuteNonQuery();
            }
        }
        public void TestInitialize()
        {
            var memoryStore = new MemoryStore();

            foreach (var testSetting in TestSettingFactory.CreateTestSettings1())
            {
                memoryStore.Add(testSetting.Name, testSetting.Value);
            }

            ConfigInfos = new[]
            {
                new ConfigInfo
                {
                    DataStore  = memoryStore,
                    Tags       = new Dictionary <string, object>(),
                    ConfigType = typeof(TestConfig)
                }
            };
        }
        private void ResetData()
        {
            var exeConfiguration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            exeConfiguration.AppSettings.Settings.Clear();
            exeConfiguration.ConnectionStrings.ConnectionStrings.Clear();

            var testSettings = TestSettingFactory.CreateTestSettings1().ToList();

            foreach (var testSetting in testSettings)
            {
                exeConfiguration.AppSettings.Settings.Add(testSetting.Name, testSetting.Value);
            }

            foreach (var testSetting in testSettings)
            {
                exeConfiguration.AppSettings.Settings.Add($"{nameof(TestConfig)}1.{testSetting.Name}", testSetting.Value);
            }

            exeConfiguration.Save(ConfigurationSaveMode.Minimal);
        }
Esempio n. 5
0
        private static void ResetData()
        {
            var baseKey = Microsoft.Win32.Registry.CurrentUser;

            using (var subKey = baseKey.OpenSubKey(@"Software\SmartConfig", writable: true))
            {
                if (subKey != null && subKey.GetSubKeyNames().Contains("Test", StringComparer.OrdinalIgnoreCase))
                {
                    subKey.DeleteSubKeyTree("Test");
                }
            }

            foreach (var testSetting in TestSettingFactory.CreateTestSettings1())
            {
                var settingPath  = SettingPath.Parse(testSetting.Name);
                var registryPath = new RegistryPath(settingPath);
                var subKeyName   = Path.Combine(@"Software\SmartConfig\Test", registryPath.Namespace);
                using (var subKey = baseKey.CreateSubKey(subKeyName, writable: true))
                {
                    subKey.SetValue(registryPath.StrongName, testSetting.Value);
                }
            }
        }