private async Task LogItems(IActivityLogger logger, IContainer container, QueueLoggerSettings loggerSettings, IQueueReader reader, int batchCount) { //write all messages var activities = GetTestActivityList(); int countExceptions = 0; for (var i = 0; i < activities.Count; ++i) { try { await logger.LogAsync(activities[i]); } catch (Exception e) { countExceptions++; //make sure that we not hiding errors... if (loggerSettings.OverflowHanding != LargeMessageMode.Error) { throw e; } } } List <Activity> completelist = new List <Activity>(); List <Activity> readActivities = new List <Activity>() { new Activity() }; while (readActivities.Count != 0) { //now read all messages, using reader readActivities = await reader.ReadBatchAsync(batchCount, TimeSpan.FromSeconds(1)); //give it some time to catch up, if the queue is muti-tennant it will take time for messages to arrive Thread.Sleep(2000); completelist.AddRange(readActivities); } //test validation if (logger is AzureQueueActivityLogger) { //make sure we got the same number we sent in. if (loggerSettings.OverflowHanding == LargeMessageMode.Trim) { Assert.AreEqual(activities.Count, completelist.Count); } else if (loggerSettings.OverflowHanding == LargeMessageMode.Discard) { if (loggerSettings.CompressMessage) { //here we expect that one messages will be dropped as after compression it is too large in size. Assert.AreEqual(activities.Count, completelist.Count + 1); } else { //here we expect that two messages will be dropped as they are too large in size. Assert.AreEqual(activities.Count, completelist.Count + 2); } } else if (loggerSettings.OverflowHanding == LargeMessageMode.Error) { //here we expect that two messages to generate errors as they are too large in size. Assert.AreEqual(activities.Count, completelist.Count + countExceptions); } } else { // these messages easily pass so count is good. Assert.AreEqual(activities.Count, completelist.Count); } }