Example #1
0
        static async Task <ActiveRunner[]> InitializeRunners(RunDescriptor runDescriptor, List <EndpointBehavior> endpointBehaviors)
        {
            var routingTable = CreateRoutingTable(endpointBehaviors);

            var runnerInitializations = endpointBehaviors.Select(async endpointBehavior =>
            {
                var endpointName = GetEndpointNameForRun(endpointBehavior);

                if (endpointName.Length > 77)
                {
                    throw new Exception($"Endpoint name '{endpointName}' is larger than 77 characters and will cause issues with MSMQ queue names. Rename the test class or endpoint.");
                }

                var runner = new ActiveRunner
                {
                    Instance     = new EndpointRunner(),
                    EndpointName = endpointName
                };

                try
                {
                    await runner.Instance.Initialize(runDescriptor, endpointBehavior, routingTable, endpointName).ConfigureAwait(false);
                }
                catch (Exception)
                {
                    Console.WriteLine($"Endpoint {runner.Instance.Name()} failed to initialize");
                    throw;
                }

                return(runner);
            });

            try
            {
                var x = await Task.WhenAll(runnerInitializations).ConfigureAwait(false);

                return(x);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Example #2
0
        static async Task<ActiveRunner[]> InitializeRunners(RunDescriptor runDescriptor, List<EndpointBehavior> endpointBehaviors)
        {
            var routingTable = CreateRoutingTable(endpointBehaviors);

            var runnerInitializations = endpointBehaviors.Select(async endpointBehavior =>
            {
                var endpointName = GetEndpointNameForRun(endpointBehavior);

                if (endpointName.Length > 77)
                {
                    throw new Exception($"Endpoint name '{endpointName}' is larger than 77 characters and will cause issues with MSMQ queue names. Rename the test class or endpoint.");
                }

                var runner = new ActiveRunner
                {
                    Instance = new EndpointRunner(),
                    EndpointName = endpointName
                };

                try
                {
                    await runner.Instance.Initialize(runDescriptor, endpointBehavior, routingTable, endpointName).ConfigureAwait(false);
                }
                catch (Exception)
                {
                    Console.WriteLine($"Endpoint {runner.Instance.Name()} failed to initialize");
                    throw;
                }

                return runner;
            });

            try
            {
                var x = await Task.WhenAll(runnerInitializations).ConfigureAwait(false);
                return x;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }