public void AddsConfigExtensionWhenNoExtensionIsSpecified()
        {
            var sut = new NetConfigManager();

            Configuration config = sut.LoadFromFile(GetPath("WithConnectionString.exe"));

            config.ConnectionStrings.ConnectionStrings[0].ConnectionString.ShouldBe("From App Config");
        }
        public void LoadsConfigurationFromMachineConfigFile()
        {
            var sut = new NetConfigManager();

            Configuration config = sut.LoadFromMachineConfiguration();

            config.EvaluationContext.IsMachineLevel.ShouldBeTrue();
        }
        public void LoadsConfigurationFromExeConfigFile()
        {
            var sut = new NetConfigManager();

            Configuration config = sut.LoadFromFile(GetPath("WithConnectionString.exe.config"));

            config.ConnectionStrings.ConnectionStrings[0].ConnectionString.ShouldBe("From App Config");
        }
Пример #4
0
 /// <summary>
 /// Uses a connection string named in the connectionStrings portion of the machine.config or app.config
 /// </summary>
 public void UseConnectionName(string connectionStringName)
 {
     if (!string.IsNullOrEmpty(connectionStringName))
     {
         var manager = new NetConfigManager(ConnectionStringConfigPath, Target);
         Connection = manager.GetConnectionString(connectionStringName);
     }
 }
        public void ThrowsIfPathDoesNotExist()
        {
            var sut = new NetConfigManager();

            sut.LoadFromFile(GetPath("FileDoesNotExist.config"));
        }
        public void ThrowsIfNullPath()
        {
            var sut = new NetConfigManager();

            sut.LoadFromFile(null);
        }
 public void ItTriesAppConfigSecond()
 {
     var sut = new NetConfigManager(null, GetPath("WithConnectionString.exe"));
     var result = sut.GetConnectionString(CONNECTION_NAME);
     Assert.That(result, Is.EqualTo("From App Config"));
 }
 public void ItFirstTriesConfigPath()
 {
     var sut = new NetConfigManager(GetPath("WithConnectionString.config"), null);
     var result = sut.GetConnectionString(CONNECTION_NAME);
     Assert.That(result, Is.EqualTo("From Arbitrary Config"));
 }
 public void ItFailsSilentlyOnMissingAppConfigConnectionString()
 {
     var sut = new NetConfigManager(null, GetPath("WithNoConnectionString.exe"));
     Assert.Throws<ArgumentException>(() =>
         sut.GetConnectionString(CONNECTION_NAME));
 }
 public void ItFailsIfTheConfigPathWasSpecifiedButCouldntResolveString()
 {
     var sut = new NetConfigManager(GetPath("WithWrongConnectionString.config"), null);
     Assert.Throws<ArgumentException>(() =>
         sut.GetConnectionString(CONNECTION_NAME));
 }