Beispiel #1
0
        public IHttpActionResult DeleteOrderItem(int orderId, int itemId)
        {
            OrderItemService service = new OrderItemService();

            if (!service.DeleteOrderItem(orderId, itemId))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Beispiel #2
0
        public static async Task DeleteOrderItem_DeletesOrderItem(
            [Frozen] ApplicationDbContext context,
            Order order,
            OrderItem orderItem,
            OrderItemService service)
        {
            context.Order.Add(order);
            order.AddOrUpdateOrderItem(orderItem);
            await context.SaveChangesAsync();

            var result = await service.DeleteOrderItem(order, order.OrderItems[0].CatalogueItem.Id);

            Assert.NotNull(result);
            result.Should().Be(1);
        }
Beispiel #3
0
        public static async Task DeleteOrderItem_SavedToDb(
            [Frozen] ApplicationDbContext context,
            Order order,
            OrderItem orderItem,
            OrderItemService service)
        {
            order.OrderItems.Should().BeEmpty();
            context.Order.Add(order);
            order.AddOrUpdateOrderItem(orderItem);
            await context.SaveChangesAsync();

            await service.DeleteOrderItem(order, order.OrderItems[0].CatalogueItem.Id);

            var expectedOrder = context.Set <Order>().First(o => o.Equals(order));

            expectedOrder.OrderItems.Should().BeEmpty();
        }
Beispiel #4
0
 public static void DeleteOrderItem_NullOrder_ThrowsException(
     CatalogueItemId catalogueItemId,
     OrderItemService service)
 {
     Assert.ThrowsAsync <ArgumentNullException>(() => _ = service.DeleteOrderItem(null, catalogueItemId));
 }