public async Task CanPostManyEventsAsync()
        {
            const int batchSize  = 250;
            const int batchCount = 10;

            await Run.InParallelAsync(batchCount, async i => {
                _eventController.Request = CreateRequestMessage(new ClaimsPrincipal(GetClientToken().ToIdentity()), true, false);
                var events           = new RandomEventGenerator().Generate(batchSize);
                var compressedEvents = await Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(events)).CompressAsync();
                var actionResult     = await _eventController.PostAsync(compressedEvents, version: 2, userAgent: "exceptionless/2.0.0.0");
                Assert.IsType <StatusCodeResult>(actionResult);
            });

            await _configuration.Client.RefreshAsync(Indices.All);

            Assert.Equal(batchCount, (await _eventQueue.GetQueueStatsAsync()).Enqueued);
            Assert.Equal(0, (await _eventQueue.GetQueueStatsAsync()).Completed);

            var processEventsJob = GetService <EventPostsJob>();
            var sw = Stopwatch.StartNew();
            await processEventsJob.RunUntilEmptyAsync();

            sw.Stop();
            _logger.Info(sw.Elapsed.ToString());

            await _configuration.Client.RefreshAsync(Indices.All);

            var stats = await _eventQueue.GetQueueStatsAsync();

            Assert.Equal(batchCount, stats.Completed);
            var minimum = batchSize * batchCount;

            Assert.InRange(await EventCountAsync(), minimum, minimum * 2);
        }
        public async Task CanPostManyEventsAsync()
        {
            const int batchSize  = 50;
            const int batchCount = 10;

            await Run.InParallelAsync(batchCount, async i => {
                var events = new RandomEventGenerator().Generate(batchSize, false);
                await SendTokenRequest(TestConstants.ApiKey, r => r
                                       .Post()
                                       .AppendPath("events")
                                       .Content(events)
                                       .StatusCodeShouldBeAccepted()
                                       );
            });

            await _configuration.Client.RefreshAsync(Indices.All);

            var stats = await _eventQueue.GetQueueStatsAsync();

            Assert.Equal(batchCount, stats.Enqueued);
            Assert.Equal(0, stats.Completed);

            var processEventsJob = GetService <EventPostsJob>();
            var sw = Stopwatch.StartNew();
            await processEventsJob.RunUntilEmptyAsync();

            sw.Stop();
            _logger.LogInformation("{Duration:g}", sw.Elapsed);

            await _configuration.Client.RefreshAsync(Indices.All);

            stats = await _eventQueue.GetQueueStatsAsync();

            Assert.Equal(batchCount, stats.Completed);
            Assert.Equal(batchSize * batchCount, await _eventRepository.CountAsync());
        }