public void RefreshConfiguration()
        {
            string sectionName = "TestSection";

            DummySection configSection = new DummySection();
            configSection.Value = 20;
            SqlConfigurationSystem configSystem = new SqlConfigurationSystem(data);
            configSystem.SaveSection(sectionName, configSection);

            DateTime lastModDate1 = GetLastModDate(sectionName);
            System.Threading.Thread.Sleep(1000);
            configSystem.RefreshConfig(sectionName);
            DateTime lastModDate2 = GetLastModDate(sectionName);

            Assert.IsFalse(lastModDate2.Equals(lastModDate1));
        }
        public void SaveAndGetTestConfiguration()
        {
            DummySection configSection = new DummySection();
            configSection.Value = 20;
            SqlConfigurationSystem configSystem = new SqlConfigurationSystem(data);
            configSystem.SaveSection("TestSection", configSection);

            DummySection configSection2 = configSystem.GetSection("TestSection") as DummySection;

            Assert.AreEqual(configSection2.Value, configSection.Value);
            
        }
 public void SaveTestConfiguration()
 {
     DummySection configSection = new DummySection();
     configSection.Value = 20;
     SqlConfigurationSystem configSystem = new SqlConfigurationSystem(data);
     configSystem.SaveSection("TestSection",configSection);
     
     //Assert that the database now has one record
     Assert.IsTrue(GetNumberofConfigSections() == 1);
 }
        public void TestInitialize()
        {
            string connectString = @"server=(local)\SQLExpress;database=Northwind;Integrated Security=true";
            string getStoredProc = @"EntLib_GetConfig";
            string setStoredProc = @"EntLib_SetConfig";
            string removeStoredProc = @"EntLib_RemoveSection";
            string refreshStoredProc = @"UpdateSectionDate";

            this.data = new SqlConfigurationData(connectString, getStoredProc, setStoredProc, refreshStoredProc, removeStoredProc);

            configSystem = new SqlConfigurationSystem(connectString, getStoredProc, setStoredProc, refreshStoredProc, removeStoredProc);
            if (SqlConfigurationManager.InitializationState == SqlConfigurationManager.InitState.NotStarted)
                SqlConfigurationManager.SetConfigurationSystem(configSystem, true);
            
            ClearConfigs();
        }
 private static void EnsureConfigurationSystem(SqlConfigurationData data)
 {
     lock (SqlConfigurationManager.initLock)
     {
         if (SqlConfigurationManager.initState >= SqlConfigurationManager.InitState.Usable)
         {
             return;
         }
         SqlConfigurationManager.initState = SqlConfigurationManager.InitState.Started;
         try
         {
             try
             {
                 SqlConfigurationManager.configSystem = new SqlConfigurationSystem(data);
                 SqlConfigurationManager.initState = SqlConfigurationManager.InitState.Usable;
             }
             catch (Exception exception1)
             {
                 throw new ConfigurationErrorsException(Properties.Resources.ExceptionConfigurationInitialization, exception1);
             }
         }
         catch
         {
             SqlConfigurationManager.initState = SqlConfigurationManager.InitState.Completed;
             throw;
         }
     }
 }
 //set public for tests!
 /// <summary>
 /// 
 /// </summary>
 /// <param name="configSystem"></param>
 /// <param name="initComplete"></param>
 public static void SetConfigurationSystem(SqlConfigurationSystem configSystem, bool initComplete)
 {
     lock (SqlConfigurationManager.initLock)
     {
         if (SqlConfigurationManager.initState != SqlConfigurationManager.InitState.NotStarted)
         {
             throw new InvalidOperationException(Properties.Resources.ExceptionConfigurationAlreadySet);
         }
         SqlConfigurationManager.configSystem = configSystem;
         if (initComplete)
         {
             SqlConfigurationManager.initState = SqlConfigurationManager.InitState.Completed;
         }
         else
         {
             SqlConfigurationManager.initState = SqlConfigurationManager.InitState.Usable;
         }
     }
 }