public void TestMethod1() { //Setup Order var pizzas = new List <Pizza>(); pizzas.Add(new Pizza { Id = 1, Status = PizzaStatus.Prep }); pizzas.Add(new Pizza { Id = 2, Status = PizzaStatus.Prep }); var order = new Order { CustomerName = "test", Pizza = pizzas }; order.Id = 0; order.Status = Status.Started; IStreamProcessingQueue queue = new KafkaStreamProcessing(); queue.QueueOrder(order); //queue.RetrieveOrders(1); // Assert.AreEqual(orders.First().CustomerName, "test"); }
public IHttpActionResult Post(OrderDTO orderDTO) { Order order = _mapper.Map <OrderDTO, Order>(orderDTO); order.Status = Status.Started; order.CreateDate = DateTime.Now; BetterRandom random = new BetterRandom(); var toppings = _distributedPizzaDbContext.Toppings.ToList(); var orderManager = new OrderManager(toppings, random); order.OrderReferenceId = GetNextSeqAPI(); //order.OrderReferenceId = Guid.NewGuid().ToString(); foreach (var pizza in order.Pizza) { int toppingsTogenerate = random.Next(1, 3); for (var x = 0; x < toppingsTogenerate; x++) { int index = random.Next(toppings.Count); var topping = toppings[index]; pizza.Toppings.Add(topping); } } _distributedPizzaDbContext.Orders.Add(order); _distributedPizzaDbContext.SaveChanges(); IStreamProcessingQueue queue; switch (order.QueueType) { case QueueType.Kafka: queue = new KafkaStreamProcessing(); break; case QueueType.AmazonSQS: queue = new AmazonSQSProcessingQueue(); break; default: queue = new KafkaStreamProcessing(); break; } queue.QueueOrder(order); return(Ok(new OrderResponseDTO { OrderReferenceId = order.OrderReferenceId })); }