public async Task AddItemToQueueShouldAddItemSuccessfully() { string queueId = "Q4"; await queuingHandler.AddItemToQueue(queueId, new DummyQueueItem { Id = 1 }); var records = queuingHandler.QueuesRecord; Assert.That(records.ContainsKey(queueId)); }
public void Setup() { queuingHandler = new QueuingHandler <DummyQueueItem>(); string queueId1 = "Q1"; string queueId2 = "Q2"; queuingHandler.AddItemToQueue(queueId1, new DummyQueueItem { Id = 1 }).Wait(); queuingHandler.AddItemToQueue(queueId2, new DummyQueueItem { Id = 2 }).Wait(); }
public async Task <IOrderQueuingResult> EnqueueOrder(Order order) { var queuingResult = queuingResultFactory.Create(); try { ValidateOrder(order); var enqueuingTasks = order.OrderItems.Select(async orderItem => { await queuingHandler.AddItemToQueue(orderItem.KitchenArea, orderItem); }); await Task.WhenAll(enqueuingTasks); queuingResult.Message = "Order placed"; queuingResult.QueuingStatus = OrderQueuingStatus.SUCCESS; return(queuingResult); } catch (InvalidOrderException ivo) { queuingResult.Message = $"Failed to place order item: {ivo.Message}"; queuingResult.QueuingStatus = OrderQueuingStatus.INVALIDORDER; return(queuingResult); } catch (Exception ex) { await RemoveItemsFromQueueAsync(order.OrderItems); queuingResult.Message = $"Failed to place order item: {ex.Message}"; queuingResult.QueuingStatus = OrderQueuingStatus.GENERALERROR; return(queuingResult); } }