コード例 #1
0
        public async void Task2_GetById_Return_NotFoundResult()
        {
            //Arrange
            var projectId = 2;
            var orderId   = 2;

            _context    = new SDCContext(dbContextOptions);
            _controller = new PurchaseOrdersController(_context);

            //Act
            var result = await _controller.GetPurchaseOrder(projectId, orderId);

            //Assert
            Assert.IsType <NotFoundResult>(result);
        }
        public async Task Should_not_return_Order_when_Order_not_existing()
        {
            const int ORDER = 11;

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

                var result = await ordersController.GetPurchaseOrder(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_get_Order_details_by_OrderNo()
        {
            const int ORDER = 1;

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

                var result = await ordersController.GetPurchaseOrder(ORDER);

                var viewResult = Assert.IsType <ActionResult <PurchaseOrder> >(result);
                var order      = Assert.IsType <PurchaseOrder>(viewResult.Value);
                Assert.NotNull(order);
                Assert.Equal(ORDER, order.OrderReference);
            }
        }
コード例 #4
0
        public async Task GetPurchaseOrderById_ActionExecute_ReturnPurchaseOrderById()
        {
            // Arrange
            int id = 1;

            _mockrepo.Setup(repo => repo.PurchaseOrder.GetPurchaseOrderById(id))
            .ReturnsAsync(GetTestPurchaseOrders().FirstOrDefault(
                              c => c.Id == id));

            // Act
            var result = await _controller.GetPurchaseOrder(id);

            // Assert
            var okResult      = Assert.IsType <OkObjectResult>(result);
            var purchaseOrder = Assert.IsType <PurchaseOrderViewModel>(okResult.Value);

            Assert.Equal(id, purchaseOrder.Id);
            Assert.Equal(1, purchaseOrder.CustomerId);
            Assert.Equal(1, purchaseOrder.EmployeeId);
        }
        public async Task Returned_Requisition_should_include_relavant_SiteManager()
        {
            const int    ORDER           = 1;
            const string SITE_MANAGER_ID = "EMP1";

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

                var result = await ordersController.GetPurchaseOrder(ORDER);

                var viewResult = Assert.IsType <ActionResult <PurchaseOrder> >(result);
                var order      = Assert.IsType <PurchaseOrder>(viewResult.Value);
                Assert.NotNull(order);
                Assert.Equal(ORDER, order.OrderReference);

                var siteManager = Assert.IsType <SiteManager>(order.SiteManager);
                Assert.NotNull(siteManager);
                Assert.Equal(SITE_MANAGER_ID, siteManager.StaffId);
            }
        }