Skip to content

Commit

Permalink
move common code to extension method
Browse files Browse the repository at this point in the history
  • Loading branch information
tsahi committed Oct 18, 2020
1 parent 274e56d commit a4b974c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,7 @@ public void Given()
oracleSettings.OracleConnectionsData.Add(oracleConnectionData);
configurationSource.Add(OracleConnectionSettings.SectionName, oracleSettings);

var dbSettings = new DatabaseSettings();
DbProviderMapping mapping = new DbProviderMapping(DbProviderMapping.DefaultOracleProviderName, typeof(OracleDatabase));
dbSettings.ProviderMappings.Add(mapping);
configurationSource.Add(DatabaseSettings.SectionName, dbSettings);

configurationSource.AddOracleDatabaseProviderMapping();

settings = new DatabaseSyntheticConfigSettings(configurationSource.GetSection);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,7 @@ public void Setup()

configSource.Add("connectionStrings", connectionStrings);

var dbSettings = new DatabaseSettings();
DbProviderMapping mapping = new DbProviderMapping(DbProviderMapping.DefaultOracleProviderName, typeof(OracleDatabase));
dbSettings.ProviderMappings.Add(mapping);
configSource.Add(DatabaseSettings.SectionName, dbSettings);
configSource.AddOracleDatabaseProviderMapping();

configSettings = new DatabaseSyntheticConfigSettings(configSource.GetSection);
}
Expand Down Expand Up @@ -459,10 +456,7 @@ public void Setup()
var oracleSettings = new OracleConnectionSettings();
configSource.Add(OracleConnectionSettings.SectionName, oracleSettings);

var dbSettings = new DatabaseSettings();
DbProviderMapping mapping = new DbProviderMapping(DbProviderMapping.DefaultOracleProviderName, typeof(OracleDatabase));
dbSettings.ProviderMappings.Add(mapping);
configSource.Add(DatabaseSettings.SectionName, dbSettings);
configSource.AddOracleDatabaseProviderMapping();

configSettings = new DatabaseSyntheticConfigSettings(configSource.GetSection);
}
Expand Down Expand Up @@ -501,10 +495,7 @@ public void Setup()
oracleSettings.OracleConnectionsData.Add(oracleConnectionData);
configSource.Add(OracleConnectionSettings.SectionName, oracleSettings);

var dbSettings = new DatabaseSettings();
DbProviderMapping mapping = new DbProviderMapping(DbProviderMapping.DefaultOracleProviderName, typeof(OracleDatabase));
dbSettings.ProviderMappings.Add(mapping);
configSource.Add(DatabaseSettings.SectionName, dbSettings);
configSource.AddOracleDatabaseProviderMapping();

configSettings = new DatabaseSyntheticConfigSettings(configSource.GetSection);
}
Expand Down
18 changes: 18 additions & 0 deletions source/Tests/Data.Tests/ConfigurationSourceExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Data.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Data.Oracle;

namespace Microsoft.Practices.EnterpriseLibrary.Data.Tests
{
internal static class ConfigurationSourceExtensions
{
internal static void AddOracleDatabaseProviderMapping(this IConfigurationSource source)
{
var dbSettings = new DatabaseSettings();
DbProviderMapping mapping = new DbProviderMapping(DbProviderMapping.DefaultOracleProviderName, typeof(OracleDatabase));
dbSettings.ProviderMappings.Add(mapping);
source.Add(DatabaseSettings.SectionName, dbSettings);
}
}
}

0 comments on commit a4b974c

Please sign in to comment.