public void SetDatabases() { try { DatabaseFactory.SetDatabases(() => databases.First(), (name) => { if (name == "sql") { return(databases.First()); } else if (name == "oracle") { return(databases.Last()); } else { return(null); } }, false); var defaultDb = DatabaseFactory.CreateDatabase(); Assert.AreEqual <Database>(databases.First(), defaultDb); Assert.AreEqual <Database>(databases.First(), DatabaseFactory.CreateDatabase("sql")); Assert.AreEqual <Database>(databases.Last(), DatabaseFactory.CreateDatabase("oracle")); Assert.IsNull(DatabaseFactory.CreateDatabase("invalid")); } finally { DatabaseFactory.ClearDatabaseProviderFactory(); } }
public override void Cleanup() { Database db = DatabaseFactory.CreateDatabase("OracleTest"); db.ExecuteNonQuery(CommandType.Text, "delete from Country where CountryCode in ('AUS','UK','CHI')"); DatabaseFactory.ClearDatabaseProviderFactory(); base.Cleanup(); }
public void ExceptionIsThrownWhenWriteLogStoredProcNameEmpty() { DatabaseFactory.ClearDatabaseProviderFactory(); DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory(this.ConfigurationSource)); LogWriterFactory factory = new LogWriterFactory((e) => this.ConfigurationSource.GetSection("loggingConfiguration11")); factory.Create(); }
public override void Cleanup() { Database db = DatabaseFactory.CreateDatabase("OracleTest"); db.ExecuteNonQuery(CommandType.Text, "delete from Country where CountryCode in ('HOL','FRA','FIN','SWI','SIN','JAP', 'RUS')"); DatabaseFactory.ClearDatabaseProviderFactory(); base.Cleanup(); }
public override void Cleanup() { dsExpectedResult.Clear(); dsExpectedResult.Dispose(); DatabaseFactory.ClearDatabaseProviderFactory(); base.Cleanup(); }
public override void Cleanup() { Database db = DatabaseFactory.CreateDatabase("OracleTest"); db.ExecuteNonQuery(CommandType.Text, "delete from SimpleDataType where Col1 in ('Data1', 'Data2','Data3')"); DatabaseFactory.ClearDatabaseProviderFactory(); base.Cleanup(); }
public override void Cleanup() { Database db = DatabaseFactory.CreateDatabase("OracleTest"); db.ExecuteNonQuery(CommandType.Text, "delete from Country where CountryCode in ('NZ','ZIM')"); dsProducts.Dispose(); dsCustomers.Dispose(); DatabaseFactory.ClearDatabaseProviderFactory(); base.Cleanup(); }
public void ExceptionThrownWhenAskingForDatabaseWithUnknownName() { DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory(new SystemConfigurationSource(false).GetSection), false); try { Database db = DatabaseFactory.CreateDatabase("ThisIsAnUnknownKey"); } finally { DatabaseFactory.ClearDatabaseProviderFactory(); } }
public void NoExceptionIsThrownWhenDatabaseFactoryIsInitializedTwiceAndNoThrowOnError() { DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory(base.ConfigurationSource), false); var db = DatabaseFactory.CreateDatabase("DefaultSql123"); Assert.IsTrue(db.ConnectionString.Contains("database=Northwind123")); DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory(), false); var db1 = DatabaseFactory.CreateDatabase("DataAccessQuickStart"); Assert.IsTrue(db1.ConnectionString.Contains("EntLibQuickStarts")); DatabaseFactory.ClearDatabaseProviderFactory(); }
public void CreateDatabaseDefaultDatabaseWithDatabaseFactory() { DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory(new SystemConfigurationSource(false).GetSection), false); try { Database db = DatabaseFactory.CreateDatabase(); Assert.IsNotNull(db); } finally { DatabaseFactory.ClearDatabaseProviderFactory(); } }
public void SettingDatabaseFactoryTheASecondTimeDoesThrows() { DatabaseFactory.ClearDatabaseProviderFactory(); DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory(sn => null)); try { DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory(sn => null)); Assert.Fail("should have thrown"); } catch (InvalidOperationException) { // expected } }
public void ConnectionStringsAreSetWhenDatabaseFactoryIsClearedAndSetAgain() { DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory(base.ConfigurationSource), false); var db = DatabaseFactory.CreateDatabase("DefaultSql123"); Assert.IsTrue(db.ConnectionString.Contains("database=Northwind123")); DatabaseFactory.ClearDatabaseProviderFactory(); DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory(), false); var db1 = DatabaseFactory.CreateDatabase("DataAccessQuickStart"); Assert.IsTrue(db1.ConnectionString.Contains("EntLibQuickStarts")); DatabaseFactory.ClearDatabaseProviderFactory(); }
static ImageDataAccess() { DatabaseFactory.ClearDatabaseProviderFactory(); DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory()); if (string.IsNullOrEmpty(_ConnectionName)) { _ConnectionName = ConfigurationManager.AppSettings["ImageDBConnectionName"]; } if (string.IsNullOrEmpty(_CommandTimeOut)) { _CommandTimeOut = ConfigurationManager.AppSettings["CommandTimeOut"]; } }
private static void ReadDb() { // Test DB access DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory()); Database db = DatabaseFactory.CreateDatabase("MyDbConnStr"); Console.WriteLine("DbConnString: " + db.ConnectionString); IDataReader reader = db.ExecuteReader(CommandType.Text, "SELECT TOP 5 * FROM TransactionActivity"); while (reader.Read()) { Console.WriteLine("Result: {0} {1} {2}", reader[0], reader[3], reader[4]); } DatabaseFactory.ClearDatabaseProviderFactory(); }
// tpdo singleton public static void SetExceptionManager() { IConfigurationSource source = ConfigurationSourceFactory.Create(); DatabaseFactory.ClearDatabaseProviderFactory(); DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory(source)); var logwriterFactory = new LogWriterFactory(source); var logWriter = logwriterFactory.Create(); Logger.Reset(); Logger.SetLogWriter(logWriter); var exceptionPolicyFactory = new ExceptionPolicyFactory(source); var exceptionManager = exceptionPolicyFactory.CreateManager(); ExceptionPolicy.SetExceptionManager(exceptionManager); }
/// <summary> /// Looks for connection string object. /// </summary> static ADO() { if (Assembly.GetEntryAssembly() != null) { var config = ConfigurationManager.OpenExeConfiguration(Assembly.GetEntryAssembly().ManifestModule.Name); var section = config.GetSection("connectionStrings") as ConnectionStringsSection; if (section.SectionInformation.IsProtected) { section.SectionInformation.UnprotectSection(); } else { section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider"); config.Save(); } } //TODO: Hace falta si no ha sido creado por otra parte de la aplicaciĆ³n DatabaseFactory.ClearDatabaseProviderFactory(); DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory()); }
static DataAccess2() { DatabaseFactory.ClearDatabaseProviderFactory(); DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory()); }
public void SettingDatabaseFactoryTheASecondTimeWithOverrideDoesNotThrow() { DatabaseFactory.ClearDatabaseProviderFactory(); DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory(sn => null)); DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory(sn => null), false); }
public void SettingDatabaseFactoryTheFirstTimeDoesNotThrow() { DatabaseFactory.ClearDatabaseProviderFactory(); DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory(sn => null)); }
public override void TestInitialize() { DatabaseFactory.ClearDatabaseProviderFactory(); base.TestInitialize(); }
static BaseGateway() { DatabaseFactory.ClearDatabaseProviderFactory(); DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory()); }
public EFDbExecuteHelper(string connectionString = "") { DatabaseFactory.ClearDatabaseProviderFactory(); DatabaseFactory.SetDatabaseProviderFactory(_providerFactory); _db = string.IsNullOrWhiteSpace(connectionString) ? _providerFactory.CreateDefault() : _providerFactory.Create(connectionString); }
public override void Cleanup() { DatabaseFactory.ClearDatabaseProviderFactory(); base.Cleanup(); }
public void Cleanup() { DatabaseFactory.ClearDatabaseProviderFactory(); }