public async Task <IActionResult> GetOrder([FromRoute] long ID) { if (!ModelState.IsValid) { return(BadRequest()); } var order = await mOrderClient.GetOrder(ID); var getproductTasks = order.OrderItems.Select(oi => mProductClient.GetProductAsync(oi.ProductID)).ToList(); var orderItems = new List <GetOrderResponseItem>(); for (int i = 0; i < getproductTasks.Count; i++) { var product = await getproductTasks[i]; orderItems.Add(new GetOrderResponseItem( id: order.OrderItems[i].ID, productID: product.ID, productName: product.Name, price: product.Price, quantity: order.OrderItems[i].Quantity )); } return(Ok(new GetOrderResponse( id: order.ID, totalPrice: orderItems.Sum(ci => ci.Price * ci.Quantity), address: order.Address, deliveryMethod: order.DeliveryMethod, orderStatus: order.OrderStatus, orderItems: orderItems ))); }
public async Task GetOrderTest() { // Arrange var id = "order-id"; _stripe.Get(Arg.Is <StripeRequest <Order> >(a => a.UrlPath == "orders/" + id), _cancellationToken) .Returns(Task.FromResult(new StripeResponse <Order>())); // Act var response = await _client.GetOrder(id, _cancellationToken); // Assert response.Should().NotBeNull(); }