コード例 #1
0
        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;
        }
コード例 #2
0
        public void RequestForEmptyNameThrows()
        {
            DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource();
            DatabaseConfigurationView     view = new DatabaseConfigurationView(configurationSource);

            view.GetConnectionStringSettings("");
        }
コード例 #3
0
        public void FailsGetConnectionStringIfConnectionStringDoesNotExist()
        {
            DictionaryConfigurationSource configurationSource = new DictionaryConfigurationSource();
            DatabaseConfigurationView     view = new DatabaseConfigurationView(configurationSource);

            view.GetConnectionStringSettings(unknownConnectionName);
        }
コード例 #4
0
		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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
ファイル: SqlDatabaseFixture.cs プロジェクト: bnantz/NCS-V2-0
        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);
        }
コード例 #9
0
ファイル: SqlDatabaseFixture.cs プロジェクト: bnantz/NCS-V2-0
        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);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        /// <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));
        }
コード例 #12
0
		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);
		}
コード例 #13
0
		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);
		}
コード例 #14
0
        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);
        }
コード例 #15
0
 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();
     }
 }
コード例 #16
0
ファイル: SqlDatabaseFixture.cs プロジェクト: bnantz/NCS-V2-0
 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();
     }
 }