private async Task <MFulfillment_AllocateFulfillableResponse> SetupFulfillable() { var allocateFulfillable = RandomFulfillable(); var allocateFulfillableResponse = await FulfillmentMicroService.AllocateFulfillableAsync(allocateFulfillable); return(allocateFulfillableResponse); }
public async Task CreateFulfillable() { var logger = ServiceScope.ServiceProvider.GetService <ILogger <FulfillmentTest> >(); var unitOfWork = CreateUnitOfWork.Timestamp(GetUniqueNow()); var allocateFulfillableResponse = await FulfillmentMicroService.AllocateFulfillableAsync(RandomFulfillable()); var fulfillableId = allocateFulfillableResponse.FulfillableId; logger.LogInformation($"Fulfillable ID = {fulfillableId}"); foreach (var allowcateFulfillableItemResponse in allocateFulfillableResponse.FulfillableItemResponses) { var fulfillableItemId = allowcateFulfillableItemResponse.FulfillableItemId; logger.LogInformation($"Fulfillable Item ID = {fulfillableItemId}"); } var eventCount = await EventProcessorMicroService.ProcessPendingEvents(); logger.LogInformation($"{eventCount} events processed."); foreach (var allowcateFulfillableItemResponse in allocateFulfillableResponse.FulfillableItemResponses) { var quantity = Random.Next(9) + 1; var fulfillableItemId = allowcateFulfillableItemResponse.FulfillableItemId; logger.LogInformation($"Fulfillable Item ID = {fulfillableItemId}"); await FulfillmentMicroService.SetFulfillmentRequestQuantity(fulfillableItemId, quantity, unitOfWork.Next()); logger.LogInformation($"Fulfillment item {fulfillableItemId} required quantity updated to {quantity}."); } eventCount = await EventProcessorMicroService.ProcessPendingEvents(); logger.LogInformation($"{eventCount} events processed."); var mShipmentRequestSummaryList = await FulfillmentMicroService.GetShipmentRequestSummariesAsync(MFulfillment_ShipmentRequestStatus.Pending, null); Assert.IsTrue(mShipmentRequestSummaryList.Summaries.Any(r => r.FulfillableId == fulfillableId)); }