Пример #1
0
        /// <summary>
        /// Set of tests with MARS enabled
        /// </summary>
        public static async Task MarsConnectionTest(CancellationToken cancellationToken)
        {
            var connection = new SqlConnection(CreateBaseConnectionString() + MarsFragment);

            try
            {
                if (await TryOpenConnectionAsync(connection, cancellationToken))
                {
                    ConnectionManager connectionManager = new ConnectionManager(connection, isMarsEnabled: true);
                    Task[]            executionTasks    = new Task[RandomHelper.Next(0, 8) * RandomHelper.Next(1, 8)];
                    for (int i = 0; i < executionTasks.Length; i++)
                    {
                        executionTasks[i] = Task.Run(() => CommandTests.RunAsync(connection.CreateCommand(), connectionManager, cancellationToken));
                    }
                    await Task.WhenAll(executionTasks);
                }
            }
            finally
            {
                // 95% change of closing (otherwise leaked)
                if (RandomHelper.NextBoolWithProbability(95))
                {
                    connection.Close();
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Set of tests with SQL Auth
        /// </summary>
        public static async Task SqlAuthConnectionTest(CancellationToken cancellationToken)
        {
            var connection = new SqlConnection(CreateBaseConnectionString());

            try
            {
                if (await TryOpenConnectionAsync(connection, cancellationToken))
                {
                    await CommandTests.RunAsync(connection.CreateCommand(), new ConnectionManager(connection, isMarsEnabled : false), cancellationToken);
                }
            }
            finally
            {
                // 95% change of closing (otherwise leaked)
                if (RandomHelper.NextBoolWithProbability(95))
                {
                    connection.Close();
                }
            }
        }