예제 #1
0
        public void AddNamedConnectionPositive()
        {
            var settings = MonahrqConfiguration.SettingsGroup.MonahrqSettings();

            Assert.AreEqual(0, settings.NamedConnections.Count);
            var expected = new NamedConnectionElement();
            var builder  = new System.Data.OleDb.OleDbConnectionStringBuilder();

            builder.Provider          = "foobar";
            expected.ConnectionString = builder.ConnectionString;
            expected.Name             = "SomeName";
            expected.SelectFrom       = "Some Table";
            expected.ControllerType   = typeof(object).AssemblyQualifiedName;
            settings.NamedConnections.Add(expected);
            MonahrqConfiguration.Save(settings);
            var newSettings = MonahrqConfiguration.SettingsGroup.MonahrqSettings();

            Assert.AreEqual(1, newSettings.NamedConnections.Count);
            var target = newSettings.NamedConnections[expected.Name];

            Assert.AreEqual(expected.Name, target.Name);
            Assert.AreEqual(expected.ControllerType, target.ControllerType);
            Assert.AreEqual(expected.SelectFrom, target.SelectFrom);
            Assert.AreEqual(expected.ConnectionString, target.ConnectionString);
        }
예제 #2
0
        public void TestChangeLastFolderPositive()
        {
            // Set the last folder as a string that's not a folder
            var    settings = MonahrqConfiguration.SettingsGroup.MonahrqSettings();
            string expected = "THIS IS NOT A FOLDER";

            settings.LastFolder = expected;
            MonahrqConfiguration.Save(settings);

            var settingsFromDisk = MonahrqConfiguration.SettingsGroup.MonahrqSettings();

            Assert.AreEqual(expected, settingsFromDisk.LastFolder);

            // TODO: do we need better tests for this item?
        }
예제 #3
0
        public void SetConnectionStringPositive()
        {
            var settings = MonahrqConfiguration.SettingsGroup.MonahrqSettings();

            Assert.IsTrue(string.IsNullOrEmpty(settings.EntityConnectionSettings.ConnectionString));
            var builder = new System.Data.OleDb.OleDbConnectionStringBuilder();

            builder.Provider = "foobar";
            settings.EntityConnectionSettings.ConnectionString = builder.ConnectionString;
            MonahrqConfiguration.Save(settings);
            var newSettings = MonahrqConfiguration.SettingsGroup.MonahrqSettings();

            Assert.AreNotSame(settings, newSettings);
            Assert.AreEqual(builder.ConnectionString, newSettings.EntityConnectionSettings.ConnectionString);
        }
예제 #4
0
        public void TestSetTimeouts()
        {
            var settings = MonahrqConfiguration.SettingsGroup.MonahrqSettings();

            double ExpectedShortTimeout = settings.ShortTimeout.TotalSeconds + 1;
            double ExpectedLongTimeout  = settings.LongTimeout.TotalSeconds + 1;

            settings.ShortTimeout = TimeSpan.FromSeconds(ExpectedShortTimeout);
            settings.LongTimeout  = TimeSpan.FromSeconds(ExpectedLongTimeout);
            MonahrqConfiguration.Save(settings);

            var settingsFromDisk = MonahrqConfiguration.SettingsGroup.MonahrqSettings();

            Assert.AreEqual(ExpectedShortTimeout, settingsFromDisk.ShortTimeout.TotalSeconds);
            Assert.AreEqual(ExpectedLongTimeout, settingsFromDisk.LongTimeout.TotalSeconds);
        }
예제 #5
0
 public void ResetConfig()
 {
     MonahrqConfiguration.Save(InitialConfig);
 }
예제 #6
0
 public void InitializeConfig()
 {
     InitialConfig = MonahrqConfiguration.SettingsGroup.MonahrqSettings();
     MonahrqConfiguration.Save(new MonahrqConfigurationSection());
 }