public void CanConnectToOracleAndExecuteAReader() { ConnectionStringSettings data = view.GetConnectionStringSettings("OracleTest"); OracleDatabase oracleDatabase = (OracleDatabase)assembler.Assemble(data.Name, data, configurationSource); DbConnection connection = oracleDatabase.CreateConnection(); Assert.IsNotNull(connection); Assert.IsTrue(connection is OracleConnection); connection.Open(); DbCommand cmd = oracleDatabase.GetSqlStringCommand("Select * from Region"); cmd.CommandTimeout = 0; }
public void RequestForEmptyNameThrows() { DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource(); DatabaseConfigurationView view = new DatabaseConfigurationView(configurationSource); view.GetConnectionStringSettings(""); }
public void FailsGetConnectionStringIfConnectionStringDoesNotExist() { DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource(); DatabaseConfigurationView view = new DatabaseConfigurationView(configurationSource); view.GetConnectionStringSettings(unknownConnectionName); }
public void RequestForNullNameThrows() { DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource(); DatabaseConfigurationView view = new DatabaseConfigurationView(configurationSource); view.GetConnectionStringSettings(null); }
public void CanGetConnectionForStringWithNoCredentials() { DatabaseConfigurationView view = new DatabaseConfigurationView(TestConfigurationSource.CreateConfigurationSource()); ConnectionStringSettings data = view.GetConnectionStringSettings("NewDatabase"); SqlDatabase sqlDatabase = new SqlDatabase(data.ConnectionString); Assert.AreEqual(@"server=(local)\sqlexpress;database=northwind;integrated security=true;", sqlDatabase.ConnectionStringWithoutCredentials); }
public void CanGetConnectionWithoutCredentials() { DatabaseConfigurationView view = new DatabaseConfigurationView(TestConfigurationSource.CreateConfigurationSource()); ConnectionStringSettings data = view.GetConnectionStringSettings("DbWithSqlServerAuthn"); SqlDatabase sqlDatabase = new SqlDatabase(data.ConnectionString); Assert.AreEqual(@"server=(local)\sqlexpress;database=northwind;", sqlDatabase.ConnectionStringWithoutCredentials); }
public void CanGetConnectionStringsIfConnectionStringExists() { DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource(); DatabaseConfigurationView view = new DatabaseConfigurationView(configurationSource); ConnectionStringSettings data = view.GetConnectionStringSettings(connectionName); Assert.IsNotNull(data); Assert.AreEqual(connectionString, data.ConnectionString); }
/// <summary> /// Returns an new instance of the type the receiver knows how to build. /// </summary> /// <param name="context">The <see cref="IBuilderContext"/> that represents the current building process.</param> /// <param name="name">The name of the instance to build, or null.</param> /// <param name="configurationSource">The source for configuration objects.</param> /// <param name="reflectionCache">The cache to use retrieving reflection information.</param> /// <returns>The new instance.</returns> public object CreateObject(IBuilderContext context, string name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache) { DatabaseConfigurationView databaseConfigurationView = new DatabaseConfigurationView(configurationSource); ConnectionStringSettings connectionStringSettings = databaseConfigurationView.GetConnectionStringSettings(name); DbSchemaProviderConfigurationView dbSchemaProviderConfigurationView = new DbSchemaProviderConfigurationView(configurationSource); DbSchemaProviderMapping mapping = dbSchemaProviderConfigurationView.GetProviderMapping(connectionStringSettings.ProviderName); return(Activator.CreateInstance(mapping.DbSchemaProviderType)); }
public void ConnectionTest() { DatabaseConfigurationView view = new DatabaseConfigurationView(TestConfigurationSource.CreateConfigurationSource()); ConnectionStringSettings data = view.GetConnectionStringSettings("NewDatabase"); SqlDatabase sqlDatabase = new SqlDatabase(data.ConnectionString); DbConnection connection = sqlDatabase.CreateConnection(); Assert.IsNotNull(connection); Assert.IsTrue(connection is SqlConnection); connection.Open(); DbCommand cmd = sqlDatabase.GetSqlStringCommand("Select * from Region"); cmd.CommandTimeout = 60; Assert.AreEqual(cmd.CommandTimeout, 60); }
public void CheckNoPasswordInConnectionStringWithPersistInfoEqualsFalse() { try { CreateUser(); DatabaseConfigurationView view = new DatabaseConfigurationView(TestConfigurationSource.CreateConfigurationSource()); ConnectionStringSettings data = view.GetConnectionStringSettings("NorthwindPersistFalse"); SqlDatabase sqlDatabase = new SqlDatabase(data.ConnectionString); DbConnection dbConnection = sqlDatabase.CreateConnection(); dbConnection.Open(); dbConnection.Close(); string connectionString = dbConnection.ConnectionString; if (connectionString.ToLower().Contains("pwd") || connectionString.ToLower().Contains("password")) { Assert.Fail(); } } finally { DeleteUser(); } }