Пример #1
0
        public void Run(int messageCount, int runtime, int timeOut, int readerCount,
                        int routeCount, bool enableChaos, IntegrationConnectionInfo.ConnectionTypes connectionType)
        {
            using (var connectionInfo = new IntegrationConnectionInfo(connectionType))
            {
                var queueName = GenerateQueueName.Create();
                var consumer  = new DotNetWorkQueue.IntegrationTests.Shared.Route.Implementation.RouteMultiTests();
                consumer.Run <LiteDbMessageQueueInit, LiteDbMessageQueueCreation>(new QueueConnection(queueName,
                                                                                                      connectionInfo.ConnectionString),
                                                                                  messageCount, runtime, timeOut, readerCount, routeCount, enableChaos, x => { Helpers.SetOptions(x, false, false, true, true); },
                                                                                  Helpers.GenerateData, Helpers.Verify, Helpers.VerifyQueueCount);
            }

            using (var connectionInfo = new IntegrationConnectionInfo(connectionType))
            {
                var queueName   = GenerateQueueName.Create();
                var logProvider = LoggerShared.Create(queueName, GetType().Name);
                using (var queueCreator =
                           new QueueCreationContainer <LiteDbMessageQueueInit>(
                               serviceRegister => serviceRegister.Register(() => logProvider, LifeStyles.Singleton)))
                {
                    var            queueConnection = new DotNetWorkQueue.Configuration.QueueConnection(queueName, connectionInfo.ConnectionString);
                    ICreationScope scope           = null;
                    var            oCreation       = queueCreator.GetQueueCreation <LiteDbMessageQueueCreation>(queueConnection);
                    try
                    {
                        oCreation.Options.EnableStatusTable = true;
                        oCreation.Options.EnableRoute       = true;

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

                        var routeTest = new RouteMultiTestsShared();
                        routeTest.RunTest <LiteDbMessageQueueInit, FakeMessageA>(queueConnection,
                                                                                 true, messageCount, logProvider, Helpers.GenerateData, Helpers.Verify, false,
                                                                                 GenerateRoutes(routeCount, 1), GenerateRoutes(routeCount, routeCount + 1), runtime,
                                                                                 timeOut, readerCount, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(12), oCreation.Scope,
                                                                                 "second(*%3)", enableChaos);

                        new VerifyQueueRecordCount(queueName, connectionInfo.ConnectionString, oCreation.Options, scope)
                        .Verify(0, false, false);
                    }
                    finally
                    {
                        oCreation?.RemoveQueue();
                        oCreation?.Dispose();
                        scope?.Dispose();
                    }
                }
            }
        }
 /// <summary>
 /// Allows a transport to register its dependencies in the IoC container.
 /// </summary>
 /// <param name="container">The container.</param>
 /// <param name="registrationType">Type of the registration.</param>
 /// <param name="queueConnection">Queue and connection information.</param>
 public abstract void RegisterImplementations(IContainer container, RegistrationTypes registrationType, QueueConnection queueConnection);