public void AppliesGroupIdentityIfNecessary()
        {
            var messageId = Guid.NewGuid().ToString();

            var preparedMessages = new[]
            {
                new PreparedMessage {
                    MessageId = messageId, Destination = "destination1", QueueUrl = "https://destination1", MessageGroupId = messageId, MessageDeduplicationId = messageId
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
            };

            var batches = Batcher.Batch(preparedMessages);

            var firstBatch  = batches.ElementAt(0);
            var firstEntry  = firstBatch.BatchRequest.Entries.ElementAt(0);
            var secondEntry = firstBatch.BatchRequest.Entries.ElementAt(1);

            Assert.AreEqual(messageId, firstEntry.MessageGroupId);
            Assert.AreEqual(messageId, firstEntry.MessageDeduplicationId);
            Assert.IsNull(secondEntry.MessageGroupId);
            Assert.IsNull(secondEntry.MessageDeduplicationId);
        }
        public void NoBatchesIfNothingToBatch()
        {
            var preparedMessages = new PreparedMessage[0]
            {
            };

            var batches = Batcher.Batch(preparedMessages);

            Assert.IsEmpty(batches);
        }
        public void MultipleBatchesForGreaterThan10Entries()
        {
            var preparedMessages = new[]
            {
                new SqsPreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new SqsPreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new SqsPreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new SqsPreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new SqsPreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new SqsPreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new SqsPreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new SqsPreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new SqsPreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new SqsPreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },

                new SqsPreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new SqsPreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new SqsPreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                }
            };

            PrecalculateSize(preparedMessages);

            var batches = Batcher.Batch(preparedMessages);

            Assert.AreEqual(2, batches.Count());
            Assert.AreEqual(10, batches.ElementAt(0).BatchRequest.Entries.Count);
            Assert.AreEqual(3, batches.ElementAt(1).BatchRequest.Entries.Count);
        }
        public void HarvestMinisreDeCulturePageIds()
        {
            var queryRequest = new QueryRequest(new ClassificationModel().GetTable())
            {
                ScanIndexForward          = true,
                ExpressionAttributeValues = new Dictionary <string, AttributeValue>
                {
                    { ":source", new AttributeValue {
                          S = MinistereDeLaCultureIndexer.SourceMinistereDeLaCulture
                      } }
                },
                ExpressionAttributeNames = new Dictionary <string, string>
                {
                    { "#source", "source" }
                },
                KeyConditionExpression = "#source = :source"
            };
            var results = QueryAll <ClassificationModel>(queryRequest, GalleryAwsCredentialsFactory.ProductionDbClient)
                          .ToDictionary(x => x.PageId);
            var lines = File.ReadAllText(@"C:\Users\peon\Downloads\base-joconde-extrait.json");
            var json  = JsonConvert.DeserializeObject <List <MonaLisaDatabaseModel> >(lines)
                        .Where(x =>
                               x.Fields != null &&
                               (x.Fields.Domn ?? string.Empty).ToLower().Contains("peinture") &&
                               !string.Equals(x.Fields.Museo, "m5031", StringComparison.OrdinalIgnoreCase) &&
                               !results.ContainsKey(x.Fields.Ref)
                               )
                        .Select(x =>
                                new ClassificationModel
            {
                Source = MinistereDeLaCultureIndexer.SourceMinistereDeLaCulture,
                PageId = x.Fields.Ref
            })
                        .ToList();

            var sqsClient          = GalleryAwsCredentialsFactory.SqsClient;
            var crawlerJsonBatches = Batcher.Batch(10, json);

            Console.WriteLine($"Sending {crawlerJsonBatches.Count} batches.");

            Parallel.ForEach(crawlerJsonBatches, crawlerJsonBatch =>
            {
                Console.WriteLine($"Sending {crawlerJsonBatch.Count} messages.");
                IndexBackend.Harvester.SendBatch(
                    sqsClient,
                    "https://sqs.us-east-1.amazonaws.com/283733643774/gonzalez-art-foundation-crawler",
                    crawlerJsonBatch
                    .Select(crawlerJson => new SendMessageBatchRequestEntry(Guid.NewGuid().ToString(), JsonConvert.SerializeObject(crawlerJson, new JsonSerializerSettings {
                    NullValueHandling = NullValueHandling.Ignore
                })))
                    .ToList()
                    );
            });
        }
Пример #5
0
        public async Task <List <T> > Get(List <T> models)
        {
            var modelKeyBatches = Batcher.Batch(100, models.Select(x => x.GetKey()).ToList());
            var fullModels      = new List <T>();

            foreach (var modelKeyBatch in modelKeyBatches)
            {
                var batchResponse = GetBatchOf100(modelKeyBatch).ConfigureAwait(false);
                fullModels.AddRange(await batchResponse);
            }
            return(fullModels);
        }
        public void NoBatchesIfNothingToBatch()
        {
            var preparedMessages = new SqsPreparedMessage[0]
            {
            };

            PrecalculateSize(preparedMessages);

            var batches = Batcher.Batch(preparedMessages);

            Assert.IsEmpty(batches);
        }
        public void DoesntUseMessageIdentityAsBatchIdentity()
        {
            var messageId = Guid.NewGuid().ToString();

            var preparedMessages = new[]
            {
                new PreparedMessage {
                    MessageId = messageId, Destination = "destination1", QueueUrl = "https://destination1"
                },
            };

            var batches = Batcher.Batch(preparedMessages);

            Assert.AreNotEqual(messageId, batches.Single().BatchRequest.Entries.Single().Id);
        }
        public void BatchPerDestination_case_sensitive()
        {
            var preparedMessages = new[]
            {
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "Destination1", QueueUrl = "https://Destination1"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
            };

            var batches = Batcher.Batch(preparedMessages);

            Assert.AreEqual(2, batches.Count());
            Assert.AreEqual("https://Destination1", batches.ElementAt(0).BatchRequest.QueueUrl);
            Assert.AreEqual("https://destination1", batches.ElementAt(1).BatchRequest.QueueUrl);
        }
        public void PutsAsManyMessagesInBatchAsPossible()
        {
            var singleMessageBody = new string('x', TransportConfiguration.MaximumMessageSize / TransportConfiguration.MaximumItemsInBatch);

            var preparedMessages = Enumerable
                                   .Range(0, 2 * TransportConfiguration.MaximumItemsInBatch)
                                   .Select(n => new SqsPreparedMessage {
                Body = singleMessageBody, Destination = "destination", QueueUrl = "https://destination"
            })
                                   .ToArray();

            PrecalculateSize(preparedMessages);

            var batches = Batcher.Batch(preparedMessages);

            Assert.AreEqual(2, batches.Count);
            Assert.AreEqual(TransportConfiguration.MaximumItemsInBatch, batches[0].BatchRequest.Entries.Count);
            Assert.AreEqual(TransportConfiguration.MaximumItemsInBatch, batches[1].BatchRequest.Entries.Count);
        }
        public void AppliesAttributes()
        {
            var preparedMessages = new[]
            {
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", MessageAttributes =
                    {
                        ["SomeKey"] = new MessageAttributeValue {
                            StringValue = "SomeValue"
                        }
                    }
                },
            };

            var batches = Batcher.Batch(preparedMessages);

            // not exactly a really robus test but good enough
            Assert.AreEqual("SomeValue", batches.Single().BatchRequest.Entries.Single().MessageAttributes["SomeKey"].StringValue);
        }
Пример #11
0
        public void SingleBatchForLessOrEqual10Entries()
        {
            var preparedMessages = new[]
            {
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
            };

            PrecalculateSize(preparedMessages);

            var batches = Batcher.Batch(preparedMessages);

            Assert.AreEqual(1, batches.Count());
            Assert.AreEqual(10, batches.ElementAt(0).BatchRequest.Entries.Count);
        }
Пример #12
0
        public async Task Harvest()
        {
            var    client          = new HttpClient();
            string resumptionToken = string.Empty;

            do
            {
                var harvestUrl = $"https://www.rijksmuseum.nl/api/oai/{ApiKey}?verb=ListRecords&set=subject:EntirePublicDomainSet&metadataPrefix=dc";
                if (!string.IsNullOrWhiteSpace(resumptionToken))
                {
                    Console.WriteLine("Harvesting from " + resumptionToken);
                    harvestUrl += $"&resumptionToken={resumptionToken}";
                }
                var harvestXml = await GetHarvestXml(client, harvestUrl, 0, 5);

                harvestXml = harvestXml
                             .Replace(@"xmlns=""http://www.openarchives.org/OAI/2.0/""", "") // Simplify xmlns
                             .Replace("oai_dc:dc", "oai_dc_dc")
                             .Replace("dc:identifier", "dc_identifier");
                var doc = new XmlDocument();
                doc.LoadXml(harvestXml);
                var records = doc.DocumentElement.SelectNodes("//ListRecords/record/metadata/oai_dc_dc/dc_identifier[2]")
                              .Cast <XmlNode>()
                              .Select(x =>
                                      new ClassificationModel
                {
                    Source = RijksmuseumIndexer.Source,
                    PageId = x.InnerText
                }
                                      )
                              .ToList();
                var batches = Batcher.Batch(10, records);
                Parallel.ForEach(batches, new ParallelOptions {
                    MaxDegreeOfParallelism = 10
                }, batch =>
                {
                    IndexBackend.Harvester.SendBatch(SqsClient, batch);
                });
                resumptionToken = doc.DocumentElement.SelectSingleNode("//ListRecords/resumptionToken")?.InnerText;
            } while (!string.IsNullOrWhiteSpace(resumptionToken));
            Console.WriteLine("Done harvesting.");
        }
        public void AppliesDelayIfNecessary()
        {
            var preparedMessages = new[]
            {
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", DelaySeconds = 150
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
            };

            var batches = Batcher.Batch(preparedMessages);

            var firstBatch  = batches.ElementAt(0);
            var firstEntry  = firstBatch.BatchRequest.Entries.ElementAt(0);
            var secondEntry = firstBatch.BatchRequest.Entries.ElementAt(1);

            Assert.AreEqual(150, firstEntry.DelaySeconds);
            Assert.AreEqual(0, secondEntry.DelaySeconds);
        }
        /// <param name="openAccessFilePath">https://github.com/metmuseum/openaccess/blob/master/MetObjects.csv</param>
        public void Harvest(
            IAmazonSQS sqsClient,
            string openAccessFilePath)
        {
            var models = new List <ClassificationModel>();

            using (TextFieldParser parser = new TextFieldParser(openAccessFilePath))
            {
                parser.TextFieldType = FieldType.Delimited;
                parser.SetDelimiters(",");
                while (!parser.EndOfData)
                {
                    string[] fields       = parser.ReadFields();
                    var      objectNumber = fields[0];
                    if (string.Equals(objectNumber, "Object Number", StringComparison.OrdinalIgnoreCase))
                    {
                        continue; // Header
                    }
                    var classification = fields[45];
                    if (!classification.Equals("paintings", StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }
                    var id    = fields[4];
                    var model = new ClassificationModel
                    {
                        Source = MetropolitanMuseumOfArtIndexer.Source,
                        PageId = id
                    };
                    models.Add(model);
                }
            }

            var batches = Batcher.Batch(10, models);

            foreach (var batch in batches)
            {
                IndexBackend.Harvester.SendBatch(sqsClient, batch);
            }
        }
        public void BatchPerDestination()
        {
            var preparedMessages = new[]
            {
                new SqsPreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new SqsPreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination2", QueueUrl = "https://destination2"
                },
                new SqsPreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination3", QueueUrl = "https://destination3"
                }
            };

            PrecalculateSize(preparedMessages);

            var batches = Batcher.Batch(preparedMessages);

            Assert.AreEqual(3, batches.Count());
            Assert.AreEqual("https://destination1", batches.ElementAt(0).BatchRequest.QueueUrl);
            Assert.AreEqual("https://destination2", batches.ElementAt(1).BatchRequest.QueueUrl);
            Assert.AreEqual("https://destination3", batches.ElementAt(2).BatchRequest.QueueUrl);
        }
        public void BatchPerDestination_MultipleBatchesForGreaterThan10Entries()
        {
            var preparedMessages = new[]
            {
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination2", QueueUrl = "https://destination2"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination2", QueueUrl = "https://destination2"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination2", QueueUrl = "https://destination2"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination2", QueueUrl = "https://destination2"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination2", QueueUrl = "https://destination2"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination2", QueueUrl = "https://destination2"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination2", QueueUrl = "https://destination2"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination2", QueueUrl = "https://destination2"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination2", QueueUrl = "https://destination2"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination2", QueueUrl = "https://destination2"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination2", QueueUrl = "https://destination2"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination2", QueueUrl = "https://destination2"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1"
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination2", QueueUrl = "https://destination2"
                },
            };

            var batches = Batcher.Batch(preparedMessages);

            Assert.AreEqual(4, batches.Count());
            Assert.AreEqual(10, batches.ElementAt(0).BatchRequest.Entries.Count);
            Assert.AreEqual(3, batches.ElementAt(1).BatchRequest.Entries.Count);
            Assert.AreEqual(10, batches.ElementAt(2).BatchRequest.Entries.Count);
            Assert.AreEqual(3, batches.ElementAt(3).BatchRequest.Entries.Count);
        }
        public void MultipleBatchesForMessagesNotFittingIntoBatchDueToMessageSize()
        {
            var preparedMessages = new[]
            {
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(256)
                },

                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(256)
                },

                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(64)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(64)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(64)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(64)
                },

                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(200)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },

                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },

                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },

                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
                new PreparedMessage {
                    MessageId = Guid.NewGuid().ToString(), Destination = "destination1", QueueUrl = "https://destination1", Body = GenerateBody(10)
                },
            };

            var batches = Batcher.Batch(preparedMessages);

            Assert.AreEqual(7, batches.Count());
            Assert.AreEqual(1, batches.ElementAt(0).BatchRequest.Entries.Count);
            Assert.AreEqual(1, batches.ElementAt(1).BatchRequest.Entries.Count);
            Assert.AreEqual(4, batches.ElementAt(2).BatchRequest.Entries.Count);
            Assert.AreEqual(6, batches.ElementAt(3).BatchRequest.Entries.Count);
            Assert.AreEqual(10, batches.ElementAt(4).BatchRequest.Entries.Count);
            Assert.AreEqual(10, batches.ElementAt(5).BatchRequest.Entries.Count);
            Assert.AreEqual(10, batches.ElementAt(6).BatchRequest.Entries.Count);
        }