public async void Run(
            int messageCount,
            LinqMethodTypes linqMethodTypes)
        {
            using (var connectionInfo = new IntegrationConnectionInfo())
            {
                var queueName   = GenerateQueueName.Create();
                var logProvider = LoggerShared.Create(queueName, GetType().Name);
                using (
                    var queueCreator =
                        new QueueCreationContainer <MemoryMessageQueueInit>(
                            serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
                {
                    try
                    {
                        using (
                            var oCreation =
                                queueCreator.GetQueueCreation <MessageQueueCreation>(queueName,
                                                                                     connectionInfo.ConnectionString)
                            )
                        {
                            var result = oCreation.CreateQueue();
                            Assert.True(result.Success, result.ErrorMessage);

                            var producer = new ProducerMethodAsyncShared();
                            var id       = Guid.NewGuid();
                            await producer.RunTestAsync <MemoryMessageQueueInit>(queueName,
                                                                                 connectionInfo.ConnectionString, true, messageCount, logProvider,
                                                                                 Helpers.GenerateData,
                                                                                 Helpers.Verify, false, 0, id, linqMethodTypes, oCreation.Scope, false).ConfigureAwait(false);
                        }
                    }
                    finally
                    {
                        using (
                            var oCreation =
                                queueCreator.GetQueueCreation <MessageQueueCreation>(queueName,
                                                                                     connectionInfo.ConnectionString)
                            )
                        {
                            oCreation.RemoveQueue();
                        }
                    }
                }
            }
        }
        public async Task Run <TTransportInit, TTransportCreate>(
            QueueConnection queueConnection,
            int messageCount,
            LinqMethodTypes linqMethodTypes,
            bool interceptors,
            bool enableChaos,
            bool sendViaBatch,
            Action <TTransportCreate> setOptions,
            Func <QueueProducerConfiguration, AdditionalMessageData> generateData,
            Action <QueueConnection, QueueProducerConfiguration, long, ICreationScope> verify)
            where TTransportInit : ITransportInit, new()
            where TTransportCreate : class, IQueueCreation
        {
            var logProvider = LoggerShared.Create(queueConnection.Queue, GetType().Name);

            using (
                var queueCreator =
                    new QueueCreationContainer <TTransportInit>(
                        serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                ICreationScope scope     = null;
                var            oCreation = queueCreator.GetQueueCreation <TTransportCreate>(queueConnection);
                try
                {
                    setOptions(oCreation);
                    var result = oCreation.CreateQueue();
                    Assert.True(result.Success, result.ErrorMessage);
                    scope = oCreation.Scope;

                    var producer = new ProducerMethodAsyncShared();
                    var id       = Guid.NewGuid();
                    await producer.RunTestAsync <TTransportInit>(queueConnection, interceptors, messageCount,
                                                                 logProvider,
                                                                 generateData,
                                                                 verify, sendViaBatch, 0, id, linqMethodTypes, oCreation.Scope, enableChaos)
                    .ConfigureAwait(false);
                }
                finally
                {
                    oCreation.RemoveQueue();
                    oCreation.Dispose();
                    scope?.Dispose();
                }
            }
        }
        public async void Run(
           int messageCount,
           bool interceptors,
           bool batchSending,
           ConnectionInfoTypes type,
           LinqMethodTypes linqMethodTypes)
        {

            var id = Guid.NewGuid();
            var queueName = GenerateQueueName.Create();
            var logProvider = LoggerShared.Create(queueName, GetType().Name);
            var producer = new ProducerMethodAsyncShared();
            var connectionString = new ConnectionInfo(type).ConnectionString;
            using (
                var queueCreator =
                    new QueueCreationContainer<RedisQueueInit>(
                        serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                try
                {
                    await producer.RunTest<RedisQueueInit>(queueName,
                        connectionString, interceptors, messageCount, logProvider, Helpers.GenerateData,
                        Helpers.Verify, batchSending, 0, id, linqMethodTypes);
                }
                finally
                {
                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation<RedisQueueCreation>(queueName,
                                connectionString)
                        )
                    {
                        oCreation.RemoveQueue();
                    }
                }
            }
        }
Exemple #4
0
        public async void Run(
            int messageCount,
            bool interceptors,
            bool batchSending,
            ConnectionInfoTypes type,
            LinqMethodTypes linqMethodTypes)
        {
            var id               = Guid.NewGuid();
            var queueName        = GenerateQueueName.Create();
            var logProvider      = LoggerShared.Create(queueName, GetType().Name);
            var producer         = new ProducerMethodAsyncShared();
            var connectionString = new ConnectionInfo(type).ConnectionString;

            using (
                var queueCreator =
                    new QueueCreationContainer <RedisQueueInit>(
                        serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                try
                {
                    await producer.RunTestAsync <RedisQueueInit>(queueName,
                                                                 connectionString, interceptors, messageCount, logProvider, Helpers.GenerateData,
                                                                 Helpers.Verify, batchSending, 0, id, linqMethodTypes, null).ConfigureAwait(false);
                }
                finally
                {
                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation <RedisQueueCreation>(queueName,
                                                                               connectionString)
                        )
                    {
                        oCreation.RemoveQueue();
                    }
                }
            }
        }
        public async void Run(
            int messageCount,
            bool interceptors,
            bool enableDelayedProcessing,
            bool enableHeartBeat,
            bool enableHoldTransactionUntilMessageCommited,
            bool enableMessageExpiration,
            bool enablePriority,
            bool enableStatus,
            bool enableStatusTable,
            bool additionalColumn,
            LinqMethodTypes linqMethodTypes)
        {

            var queueName = GenerateQueueName.Create();
            var logProvider = LoggerShared.Create(queueName, GetType().Name);
            using (
                var queueCreator =
                    new QueueCreationContainer<PostgreSqlMessageQueueInit>(
                        serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                try
                {

                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation<PostgreSqlMessageQueueCreation>(queueName,
                                ConnectionInfo.ConnectionString)
                        )
                    {
                        oCreation.Options.EnableDelayedProcessing = enableDelayedProcessing;
                        oCreation.Options.EnableHeartBeat = enableHeartBeat;
                        oCreation.Options.EnableMessageExpiration = enableMessageExpiration;
                        oCreation.Options.EnableHoldTransactionUntilMessageCommited =
                            enableHoldTransactionUntilMessageCommited;
                        oCreation.Options.EnablePriority = enablePriority;
                        oCreation.Options.EnableStatus = enableStatus;
                        oCreation.Options.EnableStatusTable = enableStatusTable;

                        if (additionalColumn)
                        {
                            oCreation.Options.AdditionalColumns.Add(new Column("OrderID", ColumnTypes.Integer, false));
                        }

                        var result = oCreation.CreateQueue();
                        Assert.True(result.Success, result.ErrorMessage);

                        var id = Guid.NewGuid();
                        var producer = new ProducerMethodAsyncShared();
                        await producer.RunTest<PostgreSqlMessageQueueInit>(queueName,
                            ConnectionInfo.ConnectionString, interceptors, messageCount, logProvider,
                            Helpers.GenerateData,
                            Helpers.Verify, false, 0, id, linqMethodTypes);
                    }
                }
                finally
                {
                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation<PostgreSqlMessageQueueCreation>(queueName,
                                ConnectionInfo.ConnectionString)
                        )
                    {
                        oCreation.RemoveQueue();
                    }

                }
            }
        }
Exemple #6
0
        public void Run(int messageCount, int runtime, int timeOut,
                        int workerCount, int readerCount, int queueSize,
                        int messageType, LinqMethodTypes linqMethodTypes)
        {
            if (Factory == null)
            {
                Factory = CreateFactory(workerCount, queueSize);
            }

            using (var connectionInfo = new IntegrationConnectionInfo())
            {
                var queueName   = GenerateQueueName.Create();
                var logProvider = LoggerShared.Create(queueName, GetType().Name);
                using (var queueCreator =
                           new QueueCreationContainer <MemoryMessageQueueInit>(
                               serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
                {
                    try
                    {
                        using (
                            var oCreation =
                                queueCreator.GetQueueCreation <MessageQueueCreation>(queueName,
                                                                                     connectionInfo.ConnectionString)
                            )
                        {
                            var result = oCreation.CreateQueue();
                            Assert.True(result.Success, result.ErrorMessage);

                            if (messageType == 1)
                            {
                                var id       = Guid.NewGuid();
                                var producer = new ProducerMethodAsyncShared();
                                producer.RunTestAsync <MemoryMessageQueueInit>(queueName,
                                                                               connectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                                                               Helpers.Verify, false, runtime, id, linqMethodTypes, oCreation.Scope).Wait(timeOut);

                                var consumer = new ConsumerMethodAsyncShared {
                                    Factory = Factory
                                };
                                consumer.RunConsumer <MemoryMessageQueueInit>(queueName, connectionInfo.ConnectionString,
                                                                              false, logProvider,
                                                                              runtime, messageCount,
                                                                              timeOut, readerCount, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), id, "second(*%10)");
                            }
                            else if (messageType == 2)
                            {
                                var id       = Guid.NewGuid();
                                var producer = new ProducerMethodAsyncShared();
                                producer.RunTestAsync <MemoryMessageQueueInit>(queueName,
                                                                               connectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                                                               Helpers.Verify, false, runtime, id, linqMethodTypes, oCreation.Scope).Wait(timeOut);

                                var consumer = new ConsumerMethodAsyncShared {
                                    Factory = Factory
                                };
                                consumer.RunConsumer <MemoryMessageQueueInit>(queueName, connectionInfo.ConnectionString,
                                                                              false, logProvider,
                                                                              runtime, messageCount,
                                                                              timeOut, readerCount, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), id, "second(*%10)");
                            }
                            else if (messageType == 3)
                            {
                                var id       = Guid.NewGuid();
                                var producer = new ProducerMethodAsyncShared();
                                producer.RunTestAsync <MemoryMessageQueueInit>(queueName,
                                                                               connectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                                                               Helpers.Verify, false, runtime, id, linqMethodTypes, oCreation.Scope).Wait(timeOut);

                                var consumer = new ConsumerMethodAsyncShared {
                                    Factory = Factory
                                };
                                consumer.RunConsumer <MemoryMessageQueueInit>(queueName, connectionInfo.ConnectionString,
                                                                              false, logProvider,
                                                                              runtime, messageCount,
                                                                              timeOut, readerCount, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), id, "second(*%10)");
                            }

                            new VerifyQueueRecordCount().Verify(oCreation.Scope, 0, true);
                        }
                    }
                    finally
                    {
                        using (
                            var oCreation =
                                queueCreator.GetQueueCreation <MessageQueueCreation>(queueName,
                                                                                     connectionInfo.ConnectionString)
                            )
                        {
                            oCreation.RemoveQueue();
                        }
                    }
                }
            }
        }
        public async void Run(
            int messageCount,
            bool interceptors,
            bool enableDelayedProcessing,
            bool enableHeartBeat,
            bool enableHoldTransactionUntilMessageCommitted,
            bool enableMessageExpiration,
            bool enablePriority,
            bool enableStatus,
            bool enableStatusTable,
            bool additionalColumn,
            LinqMethodTypes linqMethodTypes,
            bool enableChaos)
        {
            var queueName   = GenerateQueueName.Create();
            var logProvider = LoggerShared.Create(queueName, GetType().Name);

            using (
                var queueCreator =
                    new QueueCreationContainer <PostgreSqlMessageQueueInit>(
                        serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                try
                {
                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation <PostgreSqlMessageQueueCreation>(queueName,
                                                                                           ConnectionInfo.ConnectionString)
                        )
                    {
                        oCreation.Options.EnableDelayedProcessing = enableDelayedProcessing;
                        oCreation.Options.EnableHeartBeat         = enableHeartBeat;
                        oCreation.Options.EnableMessageExpiration = enableMessageExpiration;
                        oCreation.Options.EnableHoldTransactionUntilMessageCommitted =
                            enableHoldTransactionUntilMessageCommitted;
                        oCreation.Options.EnablePriority    = enablePriority;
                        oCreation.Options.EnableStatus      = enableStatus;
                        oCreation.Options.EnableStatusTable = enableStatusTable;

                        if (additionalColumn)
                        {
                            oCreation.Options.AdditionalColumns.Add(new Column("OrderID", ColumnTypes.Integer, false));
                        }

                        var result = oCreation.CreateQueue();
                        Assert.True(result.Success, result.ErrorMessage);

                        var id       = Guid.NewGuid();
                        var producer = new ProducerMethodAsyncShared();
                        await producer.RunTestAsync <PostgreSqlMessageQueueInit>(queueName,
                                                                                 ConnectionInfo.ConnectionString, interceptors, messageCount, logProvider,
                                                                                 Helpers.GenerateData,
                                                                                 Helpers.Verify, false, 0, id, linqMethodTypes, oCreation.Scope, enableChaos).ConfigureAwait(false);
                    }
                }
                finally
                {
                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation <PostgreSqlMessageQueueCreation>(queueName,
                                                                                           ConnectionInfo.ConnectionString)
                        )
                    {
                        oCreation.RemoveQueue();
                    }
                }
            }
        }
        public void Run(int messageCount, int runtime, int timeOut, int workerCount, int readerCount, int queueSize,
            bool useTransactions, int messageType, LinqMethodTypes linqMethodTypes)
        {
            if (Factory == null)
            {
                Factory = CreateFactory(workerCount, queueSize);
            }

            var queueName = GenerateQueueName.Create();
            var logProvider = LoggerShared.Create(queueName, GetType().Name);
            using (var queueCreator =
                new QueueCreationContainer<SqlServerMessageQueueInit>(
                    serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                try
                {

                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation<SqlServerMessageQueueCreation>(queueName,
                                ConnectionInfo.ConnectionString)
                        )
                    {
                        oCreation.Options.EnableDelayedProcessing = true;
                        oCreation.Options.EnableHeartBeat = !useTransactions;
                        oCreation.Options.EnableHoldTransactionUntilMessageCommited = useTransactions;
                        oCreation.Options.EnableStatus = !useTransactions;
                        oCreation.Options.EnableStatusTable = true;

                        var result = oCreation.CreateQueue();
                        Assert.True(result.Success, result.ErrorMessage);
                        var id = Guid.NewGuid();
                        if (messageType == 1)
                        {
                            var producer = new ProducerMethodAsyncShared();
                            producer.RunTest<SqlServerMessageQueueInit>(queueName,
                                ConnectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                Helpers.Verify, false, runtime, id, linqMethodTypes).Wait(timeOut);

                            var consumer = new ConsumerMethodAsyncShared {Factory = Factory};
                            consumer.RunConsumer<SqlServerMessageQueueInit>(queueName, ConnectionInfo.ConnectionString,
                                false, logProvider,
                                runtime, messageCount,
                                timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), id);
                        }
                        else if (messageType == 2)
                        {
                            var producer = new ProducerMethodAsyncShared();
                            producer.RunTest<SqlServerMessageQueueInit>(queueName,
                                ConnectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                Helpers.Verify, false, runtime, id, linqMethodTypes).Wait(timeOut);

                            var consumer = new ConsumerMethodAsyncShared {Factory = Factory};
                            consumer.RunConsumer<SqlServerMessageQueueInit>(queueName, ConnectionInfo.ConnectionString,
                                false, logProvider,
                                runtime, messageCount,
                                timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), id);
                        }
                        else if (messageType == 3)
                        {
                            var producer = new ProducerMethodAsyncShared();
                            producer.RunTest<SqlServerMessageQueueInit>(queueName,
                                ConnectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                Helpers.Verify, false, runtime, id, linqMethodTypes).Wait(timeOut);

                            var consumer = new ConsumerMethodAsyncShared {Factory = Factory};
                            consumer.RunConsumer<SqlServerMessageQueueInit>(queueName, ConnectionInfo.ConnectionString,
                                false, logProvider,
                                runtime, messageCount,
                                timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), id);
                        }

                        new VerifyQueueRecordCount(queueName, oCreation.Options).Verify(0, false, false);
                    }
                }
                finally
                {
                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation<SqlServerMessageQueueCreation>(queueName,
                                ConnectionInfo.ConnectionString)
                        )
                    {
                        oCreation.RemoveQueue();
                    }
                }
            }
        }
Exemple #9
0
        public void Run(int messageCount, int runtime, int timeOut, int workerCount, int readerCount, int queueSize,
                        bool useTransactions, int messageType, LinqMethodTypes linqMethodTypes, bool enableChaos)
        {
            if (Factory == null)
            {
                Factory = CreateFactory(workerCount, queueSize);
            }

            var queueName   = GenerateQueueName.Create();
            var logProvider = LoggerShared.Create(queueName, GetType().Name);

            using (var queueCreator =
                       new QueueCreationContainer <PostgreSqlMessageQueueInit>(
                           serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                try
                {
                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation <PostgreSqlMessageQueueCreation>(queueName,
                                                                                           ConnectionInfo.ConnectionString)
                        )
                    {
                        oCreation.Options.EnableDelayedProcessing = true;
                        oCreation.Options.EnableHeartBeat         = !useTransactions;
                        oCreation.Options.EnableHoldTransactionUntilMessageCommitted = useTransactions;
                        oCreation.Options.EnableStatus      = !useTransactions;
                        oCreation.Options.EnableStatusTable = true;

                        var result = oCreation.CreateQueue();
                        Assert.True(result.Success, result.ErrorMessage);
                        var id = Guid.NewGuid();
                        if (messageType == 1)
                        {
                            var producer = new ProducerMethodAsyncShared();
                            producer.RunTestAsync <PostgreSqlMessageQueueInit>(queueName,
                                                                               ConnectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                                                               Helpers.Verify, false, runtime, id, linqMethodTypes, oCreation.Scope, false).Wait(timeOut);

                            var consumer = new ConsumerMethodAsyncShared {
                                Factory = Factory
                            };
                            consumer.RunConsumer <PostgreSqlMessageQueueInit>(queueName, ConnectionInfo.ConnectionString,
                                                                              false, logProvider,
                                                                              runtime, messageCount,
                                                                              timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), id, "second(*%3)", enableChaos);
                        }
                        else if (messageType == 2)
                        {
                            var producer = new ProducerMethodAsyncShared();
                            producer.RunTestAsync <PostgreSqlMessageQueueInit>(queueName,
                                                                               ConnectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                                                               Helpers.Verify, false, runtime, id, linqMethodTypes, oCreation.Scope, false).Wait(timeOut);

                            var consumer = new ConsumerMethodAsyncShared {
                                Factory = Factory
                            };
                            consumer.RunConsumer <PostgreSqlMessageQueueInit>(queueName, ConnectionInfo.ConnectionString,
                                                                              false, logProvider,
                                                                              runtime, messageCount,
                                                                              timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), id, "second(*%3)", enableChaos);
                        }
                        else if (messageType == 3)
                        {
                            var producer = new ProducerMethodAsyncShared();
                            producer.RunTestAsync <PostgreSqlMessageQueueInit>(queueName,
                                                                               ConnectionInfo.ConnectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                                                               Helpers.Verify, false, runtime, id, linqMethodTypes, oCreation.Scope, false).Wait(timeOut);

                            var consumer = new ConsumerMethodAsyncShared {
                                Factory = Factory
                            };
                            consumer.RunConsumer <PostgreSqlMessageQueueInit>(queueName, ConnectionInfo.ConnectionString,
                                                                              false, logProvider,
                                                                              runtime, messageCount,
                                                                              timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), id, "second(*%3)", enableChaos);
                        }

                        new VerifyQueueRecordCount(queueName, oCreation.Options).Verify(0, false, false);
                    }
                }
                finally
                {
                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation <PostgreSqlMessageQueueCreation>(queueName,
                                                                                           ConnectionInfo.ConnectionString)
                        )
                    {
                        oCreation.RemoveQueue();
                    }
                }
            }
        }
        public void Run(int messageCount, int runtime, int timeOut, int workerCount, int readerCount, int queueSize,
            int messageType, ConnectionInfoTypes type, LinqMethodTypes linqMethodTypes)
        {
            if (Factory == null)
            {
                Factory = CreateFactory(workerCount, queueSize);
            }

            var queueName = GenerateQueueName.Create();
            var logProvider = LoggerShared.Create(queueName, GetType().Name);
            var connectionString = new ConnectionInfo(type).ConnectionString;
            using (var queueCreator =
                new QueueCreationContainer<RedisQueueInit>(
                    serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                try
                {
                    var id = Guid.NewGuid();
                    if (messageType == 1)
                    {
                        var producer = new ProducerMethodAsyncShared();
                        producer.RunTest<RedisQueueInit>(queueName,
                            connectionString, false, messageCount, logProvider, Helpers.GenerateData,
                            Helpers.Verify, false, runtime, id, linqMethodTypes).Wait(timeOut);

                        var consumer = new ConsumerMethodAsyncShared {Factory = Factory};
                        consumer.RunConsumer<RedisQueueInit>(queueName, connectionString, false,
                            logProvider,
                            runtime, messageCount,
                            timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), id);
                    }
                    else if (messageType == 2)
                    {
                        var producer = new ProducerMethodAsyncShared();
                        producer.RunTest<RedisQueueInit>(queueName,
                            connectionString, false, messageCount, logProvider, Helpers.GenerateData,
                            Helpers.Verify, false, runtime, id, linqMethodTypes).Wait(timeOut);

                        var consumer = new ConsumerMethodAsyncShared {Factory = Factory};
                        consumer.RunConsumer<RedisQueueInit>(queueName, connectionString, false,
                            logProvider,
                            runtime, messageCount,
                            timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), id);
                    }
                    else if (messageType == 3)
                    {
                        var producer = new ProducerMethodAsyncShared();
                        producer.RunTest<RedisQueueInit>(queueName,
                            connectionString, false, messageCount, logProvider, Helpers.GenerateData,
                            Helpers.Verify, false, runtime, id, linqMethodTypes).Wait(timeOut);


                        var consumer = new ConsumerMethodAsyncShared { Factory = Factory};
                        consumer.RunConsumer<RedisQueueInit>(queueName, connectionString, false,
                            logProvider,
                            runtime, messageCount,
                            timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), id);
                    }

                    using (var count = new VerifyQueueRecordCount(queueName, connectionString))
                    {
                        count.Verify(0, false, -1);
                    }
                }
                finally
                {

                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation<RedisQueueCreation>(queueName,
                               connectionString)
                        )
                    {
                        oCreation.RemoveQueue();
                    }
                }
            }
        }
        public void Run <TTransportInit, TTransportCreate>(
            QueueConnection queueConnection,
            int messageCount, int runtime, int timeOut, int workerCount, int readerCount, int queueSize,
            int messageType,
            LinqMethodTypes linqMethodTypes,
            bool enableChaos,
            Action <TTransportCreate> setOptions,
            Func <QueueProducerConfiguration, AdditionalMessageData> generateData,
            Action <QueueConnection, QueueProducerConfiguration, long, ICreationScope> verify,
            Action <QueueConnection, IBaseTransportOptions, ICreationScope, int, bool, bool> verifyQueueCount)
            where TTransportInit : ITransportInit, new()
            where TTransportCreate : class, IQueueCreation
        {
            if (Factory == null)
            {
                Factory = CreateFactory(workerCount, queueSize);
            }

            var logProvider = LoggerShared.Create(queueConnection.Queue, GetType().Name);

            using (var queueCreator =
                       new QueueCreationContainer <TTransportInit>(
                           serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                ICreationScope scope     = null;
                var            oCreation = queueCreator.GetQueueCreation <TTransportCreate>(queueConnection);
                try
                {
                    setOptions(oCreation);
                    var result = oCreation.CreateQueue();
                    Assert.True(result.Success, result.ErrorMessage);
                    scope = oCreation.Scope;

                    if (messageType == 1)
                    {
                        var id       = Guid.NewGuid();
                        var producer = new ProducerMethodAsyncShared();
                        producer.RunTestAsync <TTransportInit>(queueConnection, false, messageCount, logProvider,
                                                               generateData,
                                                               verify, false, runtime, id, linqMethodTypes, oCreation.Scope, false).Wait(timeOut);

                        var consumer = new ConsumerMethodAsyncShared {
                            Factory = Factory
                        };
                        consumer.RunConsumer <TTransportInit>(queueConnection,
                                                              false, logProvider,
                                                              runtime, messageCount,
                                                              timeOut, readerCount, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), id,
                                                              "second(*%10)", enableChaos, scope);
                    }
                    else if (messageType == 2)
                    {
                        var id       = Guid.NewGuid();
                        var producer = new ProducerMethodAsyncShared();
                        producer.RunTestAsync <TTransportInit>(queueConnection, false, messageCount, logProvider,
                                                               generateData,
                                                               verify, false, runtime, id, linqMethodTypes, oCreation.Scope, false).Wait(timeOut);

                        var consumer = new ConsumerMethodAsyncShared {
                            Factory = Factory
                        };
                        consumer.RunConsumer <TTransportInit>(queueConnection,
                                                              false, logProvider,
                                                              runtime, messageCount,
                                                              timeOut, readerCount, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), id,
                                                              "second(*%10)", enableChaos, scope);
                    }
                    else if (messageType == 3)
                    {
                        var id       = Guid.NewGuid();
                        var producer = new ProducerMethodAsyncShared();
                        producer.RunTestAsync <TTransportInit>(queueConnection, false, messageCount, logProvider,
                                                               generateData,
                                                               verify, false, runtime, id, linqMethodTypes, oCreation.Scope, false).Wait(timeOut);

                        var consumer = new ConsumerMethodAsyncShared {
                            Factory = Factory
                        };
                        consumer.RunConsumer <TTransportInit>(queueConnection,
                                                              false, logProvider,
                                                              runtime, messageCount,
                                                              timeOut, readerCount, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(35), id,
                                                              "second(*%10)", enableChaos, scope);
                    }

                    verifyQueueCount(queueConnection, oCreation.BaseTransportOptions, scope, 0, false, false);
                }
                finally
                {
                    oCreation.RemoveQueue();
                    oCreation.Dispose();
                    scope?.Dispose();
                }
            }
        }
        public void Run(int messageCount, int runtime, int timeOut, int workerCount, int readerCount, int queueSize,
                        int messageType, ConnectionInfoTypes type, LinqMethodTypes linqMethodTypes)
        {
            if (Factory == null)
            {
                Factory = CreateFactory(workerCount, queueSize);
            }

            var queueName        = GenerateQueueName.Create();
            var logProvider      = LoggerShared.Create(queueName, GetType().Name);
            var connectionString = new ConnectionInfo(type).ConnectionString;

            using (var queueCreator =
                       new QueueCreationContainer <RedisQueueInit>(
                           serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
            {
                try
                {
                    var id = Guid.NewGuid();
                    if (messageType == 1)
                    {
                        var producer = new ProducerMethodAsyncShared();
                        producer.RunTestAsync <RedisQueueInit>(queueName,
                                                               connectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                                               Helpers.Verify, false, runtime, id, linqMethodTypes, null).Wait(timeOut);

                        var consumer = new ConsumerMethodAsyncShared {
                            Factory = Factory
                        };
                        consumer.RunConsumer <RedisQueueInit>(queueName, connectionString, false,
                                                              logProvider,
                                                              runtime, messageCount,
                                                              timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), id, "second(*%3)");
                    }
                    else if (messageType == 2)
                    {
                        var producer = new ProducerMethodAsyncShared();
                        producer.RunTestAsync <RedisQueueInit>(queueName,
                                                               connectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                                               Helpers.Verify, false, runtime, id, linqMethodTypes, null).Wait(timeOut);

                        var consumer = new ConsumerMethodAsyncShared {
                            Factory = Factory
                        };
                        consumer.RunConsumer <RedisQueueInit>(queueName, connectionString, false,
                                                              logProvider,
                                                              runtime, messageCount,
                                                              timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), id, "second(*%3)");
                    }
                    else if (messageType == 3)
                    {
                        var producer = new ProducerMethodAsyncShared();
                        producer.RunTestAsync <RedisQueueInit>(queueName,
                                                               connectionString, false, messageCount, logProvider, Helpers.GenerateData,
                                                               Helpers.Verify, false, runtime, id, linqMethodTypes, null).Wait(timeOut);


                        var consumer = new ConsumerMethodAsyncShared {
                            Factory = Factory
                        };
                        consumer.RunConsumer <RedisQueueInit>(queueName, connectionString, false,
                                                              logProvider,
                                                              runtime, messageCount,
                                                              timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), id, "second(*%3)");
                    }

                    using (var count = new VerifyQueueRecordCount(queueName, connectionString))
                    {
                        count.Verify(0, false, -1);
                    }
                }
                finally
                {
                    using (
                        var oCreation =
                            queueCreator.GetQueueCreation <RedisQueueCreation>(queueName,
                                                                               connectionString)
                        )
                    {
                        oCreation.RemoveQueue();
                    }
                }
            }
        }