public async Task DeletePurchaseOrder_ReturnBadRequest_ExistRelatedEntity()
        {
            //Arrange
            int id = 1;
            List <OrderDetail> list = new List <OrderDetail>();

            list.Add(new OrderDetail());
            _mockrepo.Setup(repo => repo.OrderDetail.OrderDetailsByPurchaseOrder(id)).ReturnsAsync(list);
            _mockrepo.Setup(repo => repo.PurchaseOrder.DeletePurchaseOrder((PurchaseOrder)null));
            //Act
            var result = await _controller.DeletePurchaseOrder(id);

            //Assert
            var badRequest = Assert.IsType <BadRequestObjectResult>(result);

            badRequest.Value.Should().Be(LogMessage.DeleteError(nameof(PurchaseOrder), id, nameof(OrderDetail)));
        }
        public async Task Cannot_delete_Order_when_it_not_exist()
        {
            const int ORDER = 11;

            using (var context = new ProcurementDbContext(ContextOptions))
            {
                PurchaseOrdersController ordersController = new PurchaseOrdersController(context);

                var result = await ordersController.DeletePurchaseOrder(ORDER);

                var viewResult = Assert.IsType <ActionResult <PurchaseOrder> >(result);
                Assert.IsNotType <PurchaseOrder>(viewResult.Value);
                var response = Assert.IsType <NotFoundResult>(viewResult.Result);
                Assert.Equal(404, response.StatusCode);
            }
        }
        public async Task Can_delete_Order_by_OderReference()
        {
            const int ORDER = 1;

            using (var context = new ProcurementDbContext(ContextOptions))
            {
                PurchaseOrdersController ordersController = new PurchaseOrdersController(context);

                var result = await ordersController.DeletePurchaseOrder(ORDER);

                var viewResult = Assert.IsType <ActionResult <PurchaseOrder> >(result);
                var model      = Assert.IsType <PurchaseOrder>(viewResult.Value);

                Assert.Equal(ORDER, model.OrderReference);
            }
        }