コード例 #1
0
        public void CreateOrderItem_OkResult()
        {
            //Arrange
            var controller = new OrderItemsController(_uow);
            var orderItem  = new OrderItem
            {
                OrderId   = 3,
                ProductId = 2,
                Quantity  = 5
            };

            //Act
            var result       = controller.Post(orderItem);
            var created      = controller.Get(orderItem.OrderItemId);
            var createdOrder = created.Value.Should().BeAssignableTo <OrderItem>().Subject;

            //Assert
            Assert.IsType <CreatedAtRouteResult>(result.Result);
            Assert.Equal(createdOrder.OrderItemId, orderItem.OrderItemId);
            Assert.Equal(createdOrder.OrderId, orderItem.OrderId);
            Assert.Equal(createdOrder.ProductId, orderItem.ProductId);
            Assert.Equal(createdOrder.Quantity, orderItem.Quantity);
        }