Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new SqlConnection object
        /// </summary>
        public DbConnection CreateSqlConnection(string connectionString, string azureAccountToken)
        {
            RetryPolicy connectionRetryPolicy = RetryPolicyFactory.CreateDefaultConnectionRetryPolicy();
            RetryPolicy commandRetryPolicy    = RetryPolicyFactory.CreateDefaultConnectionRetryPolicy();

            return(new ReliableSqlConnection(connectionString, connectionRetryPolicy, commandRetryPolicy, azureAccountToken));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Helper method to create an integrated auth reliable connection for testing.
        /// </summary>
        private DbConnection CreateTestConnection()
        {
            SqlConnectionStringBuilder csb = CreateTestConnectionStringBuilder();

            RetryPolicy connectionRetryPolicy = RetryPolicyFactory.CreateDefaultConnectionRetryPolicy();
            RetryPolicy commandRetryPolicy    = RetryPolicyFactory.CreateDefaultConnectionRetryPolicy();

            ReliableSqlConnection connection = new ReliableSqlConnection(csb.ConnectionString, connectionRetryPolicy, commandRetryPolicy);

            return(connection);
        }
        public void ReliableSqlConnectionUsesAzureToken()
        {
            ConnectionDetails details = TestObjects.GetTestConnectionDetails();

            details.UserName = "";
            details.Password = "";
            string      connectionString  = ConnectionService.BuildConnectionString(details);
            string      azureAccountToken = "testAzureAccountToken";
            RetryPolicy retryPolicy       = RetryPolicyFactory.CreateDefaultConnectionRetryPolicy();

            // If I create a ReliableSqlConnection using an azure account token
            var reliableConnection = new ReliableSqlConnection(connectionString, retryPolicy, retryPolicy, azureAccountToken);

            // Then the connection's azureAccountToken gets set
            Assert.Equal(azureAccountToken, reliableConnection.GetUnderlyingConnection().AccessToken);
        }
Ejemplo n.º 4
0
 public void RetryPolicyFactoryConstructsPoliciesSuccessfully()
 {
     TestUtils.RunIfWindows(() =>
     {
         Assert.NotNull(RetryPolicyFactory.CreateColumnEncryptionTransferRetryPolicy());
         Assert.NotNull(RetryPolicyFactory.CreateDatabaseCommandRetryPolicy());
         Assert.NotNull(RetryPolicyFactory.CreateDataScriptUpdateRetryPolicy());
         Assert.NotNull(RetryPolicyFactory.CreateDefaultConnectionRetryPolicy());
         Assert.NotNull(RetryPolicyFactory.CreateDefaultDataConnectionRetryPolicy());
         Assert.NotNull(RetryPolicyFactory.CreateDefaultDataSqlCommandRetryPolicy());
         Assert.NotNull(RetryPolicyFactory.CreateDefaultDataTransferRetryPolicy());
         Assert.NotNull(RetryPolicyFactory.CreateDefaultSchemaCommandRetryPolicy(true));
         Assert.NotNull(RetryPolicyFactory.CreateDefaultSchemaConnectionRetryPolicy());
         Assert.NotNull(RetryPolicyFactory.CreateElementCommandRetryPolicy());
         Assert.NotNull(RetryPolicyFactory.CreateFastDataRetryPolicy());
         Assert.NotNull(RetryPolicyFactory.CreateNoRetryPolicy());
         Assert.NotNull(RetryPolicyFactory.CreatePrimaryKeyCommandRetryPolicy());
         Assert.NotNull(RetryPolicyFactory.CreateSchemaCommandRetryPolicy(6));
         Assert.NotNull(RetryPolicyFactory.CreateSchemaConnectionRetryPolicy(6));
     });
 }