public void UpdateOrder_OkResult() { //Arrange var controller = new OrderItemsController(_uow); var orderItemId = 2; var orderItem = new OrderItem { OrderItemId = orderItemId, OrderId = 3, ProductId = 2, Quantity = 4 }; //Act var result = controller.Put(orderItemId, orderItem); var updated = controller.Get(orderItem.OrderItemId); var updatedOrder = updated.Value.Should().BeAssignableTo <OrderItem>().Subject; //Assert Assert.IsType <OkResult>(result.Result); Assert.Equal(updatedOrder.OrderItemId, orderItem.OrderItemId); Assert.Equal(updatedOrder.OrderId, orderItem.OrderId); Assert.Equal(updatedOrder.ProductId, orderItem.ProductId); Assert.Equal(updatedOrder.Quantity, orderItem.Quantity); }
public void UpdateOrderItem_BadResult() { //Arrange var controller = new OrderItemsController(_uow); var orderItemId = 2; //Teste Faltando o Pedido var orderItem = new OrderItem { OrderItemId = orderItemId, ProductId = 2, Quantity = 4 }; //Act var result = controller.Put(orderItemId, orderItem); //Assert Assert.IsType <BadRequestObjectResult>(result.Result); }