public async Task GivenADatabaseRecord_ThenItemGetsPutOnRetailerBasedQueue(string identifier, string retailer) { await AddItem(identifier, retailer); await GetItemsFunctions.Run(new TimerStub(), _tableReference, _storageAccount, new StubLogger()); var queueName = $"{retailer}-item-queue".ToLower(); var queueClient = _storageAccount.CreateCloudQueueClient(); var queueReference = queueClient.GetQueueReference(queueName); var firstMessage = await queueReference.GetMessageAs <QueueItem>(); Assert.Equal(identifier, firstMessage.Id); }
public async Task GivenAMultipleItemsInTheDatabaseWhenRunningTheFunction_ItemIsAddedToTheQueue() { var identifiers = new List <string> { "B07Q", "B07P", "B07L" }; foreach (var identifier in identifiers) { await AddItem(identifier); } await GetItemsFunctions.Run(new TimerStub(), _tableReference, _storageAccount, new StubLogger()); var queueClient = _storageAccount.CreateCloudQueueClient(); var queueReference = queueClient.GetQueueReference("amazon-item-queue"); var messages = await queueReference.GetMessagesAs <QueueItem>(3); Assert.Contains(messages, message => message.Id == "B07Q"); Assert.Contains(messages, message => message.Id == "B07P"); Assert.Contains(messages, message => message.Id == "B07L"); }