Пример #1
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 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 ItFailsSilentlyOnMissingAppConfigConnectionString()
 {
     var sut = new NetConfigManager(null, GetPath("WithNoConnectionString.exe"));
     Assert.Throws<ArgumentException>(() =>
         sut.GetConnectionString(CONNECTION_NAME));
 }
 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 ItFailsIfTheConfigPathWasSpecifiedButCouldntResolveString()
 {
     var sut = new NetConfigManager(GetPath("WithWrongConnectionString.config"), null);
     Assert.Throws<ArgumentException>(() =>
         sut.GetConnectionString(CONNECTION_NAME));
 }