コード例 #1
0
        public async Task Test()
        {
            try
            {
                var hostingEnvironment = new IntegrationTestHostingEnvironment();

                var serviceProvider = new ServiceProviderFactory().Build(hostingEnvironment);

                var config = hostingEnvironment.ConfigFactory();

                var commandDispatcher = serviceProvider.GetService <ICommandDispatcher>();

                using (var smallDataSetStream = Assembly.GetExecutingAssembly()
                                                .GetManifestResourceStream(typeof(Basic), "small-make-model-data-set.csv"))
                {
                    await commandDispatcher.DispatchAsync(new StoreObjectCommand
                    {
                        Key        = "raw/smallDataSet.csv",
                        DataStream = smallDataSetStream
                    });
                }

                await serviceProvider.GetService <IQueueClient>().Enqueue(config.RawDataQueueName, "raw/smallDataSet.csv");

                await commandDispatcher.DispatchAsync(new WorkerManagerCommand());

                await WaitUntil(async() => (await commandDispatcher.DispatchAsync(new IsTerminatedCommand())).Result);

                var finalObjectKey = serviceProvider.GetService <IQueueClient>().Dequeue(serviceProvider.GetService <IConfig>().FinalReducedQueueName).Result.First().Message;

                var finalReductionResult = await commandDispatcher.GetObjectAsString(finalObjectKey);

                finalReductionResult.Split(Environment.NewLine).Count(x => !string.IsNullOrEmpty(x)).ShouldBe(7);
                finalReductionResult.ShouldContain("NULL,2");
                finalReductionResult.ShouldContain("YAMAHA,1");
                finalReductionResult.ShouldContain("MERCEDES,1");
                finalReductionResult.ShouldContain("VOLKSWAGEN,1");
                finalReductionResult.ShouldContain("OTHER BRITISH,1");
                finalReductionResult.ShouldContain("BMW,2");
                finalReductionResult.ShouldContain("FORD,1");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Demystify());
                throw;
            }
        }
コード例 #2
0
        static async Task Main(string[] args)
        {
            var serviceProvider = new ServiceProviderFactory().Generate();
            var gerenciador     = serviceProvider.GetService <IGerenciadorService>();

            var ordemExecucao = new Dictionary <ETipoDado, IAnaliseService>
            {
                { ETipoDado.Cliente, new ClientesAnaliseService() },
                { ETipoDado.Vendedor, new VendedoresAnaliseService() },
                { ETipoDado.Venda, new VendasAnaliseService() },
            };

            await gerenciador.ExecutarProcesso(ordemExecucao);
        }
コード例 #3
0
        private static async Task MainAsync(params string[] args)
        {
            //var hostingEnvironment = new AwsLambdaHostingEnvironment();
            var hostingEnvironment = new CommandLineLocalHostingEnvironment();
            var serviceProvider    = new ServiceProviderFactory().Build(hostingEnvironment);
            var config             = serviceProvider.GetService <IConfig>();

            foreach (var arg in args)
            {
                await serviceProvider.GetService <IQueueClient>().Enqueue(config.RawDataQueueName, arg);
            }

            var commandDispatcher = serviceProvider.GetService <IFrameworkCommandDispatcher>();

#pragma warning disable 4014
            commandDispatcher.DispatchAsync(new WorkerManagerCommand());
#pragma warning restore 4014

            var sw = new Stopwatch();
            sw.Start();
            BlockUntilJobTerminates(commandDispatcher);
            sw.Stop();
            System.Console.WriteLine($"That took {sw.Elapsed.TotalSeconds:0.0}s");
        }