public async Task TestGetOrdersAsync()
        {
            // Arrange
            var logger       = LoggerMocker.GetLogger <SalesController>();
            var salesService = ServiceMocker.GetSalesService();

            using (var controller = new SalesController(logger, salesService))
            {
                // Act
                var response = await controller.GetOrdersAsync() as ObjectResult;

                var value = response.Value as IPagedResponse <OrderInfo>;

                // Assert
                Assert.False(value.DidError);
            }
        }
Exemple #2
0
        public async Task GetProductsTestAsync()
        {
            // Arrange
            var logger            = LoggerMocker.GetLogger <ProductionController>();
            var productionService = ServiceMocker.GetProductionService();

            using (var controller = new ProductionController(logger, productionService))
            {
                // Act
                var response = await controller.GetProductsAsync() as ObjectResult;

                var value = response.Value as IPagedResponse <Product>;

                // Assert
                Assert.False(value.DidError);
            }
        }
        public async Task TestGetCreateOrderRequestAsync()
        {
            // Arrange
            var logger       = LoggerMocker.GetLogger <SalesController>();
            var salesService = ServiceMocker.GetSalesService();

            using (var controller = new SalesController(logger, salesService))
            {
                // Act
                var response = await controller.GetCreateOrderRequestAsync() as ObjectResult;

                var value = response.Value as ISingleResponse <CreateOrderRequest>;

                // Assert
                Assert.False(value.DidError);
                Assert.True(value.Model.Products.Count() >= 0);
            }
        }
        public async Task TestGetOrdersByEmployeeAsync()
        {
            // Arrange
            var logger       = LoggerMocker.GetLogger <SalesController>();
            var salesService = ServiceMocker.GetSalesService();
            var employeeID   = 1;

            using (var controller = new SalesController(logger, salesService))
            {
                // Act
                var response = await controller.GetOrdersAsync(employeeID : employeeID) as ObjectResult;

                var value = response.Value as IPagedResponse <OrderInfo>;

                // Assert
                Assert.False(value.DidError);
                Assert.True(value.Model.Where(item => item.EmployeeID == employeeID).Count() == value.Model.Count());
            }
        }
        public async Task TestGetCreateOrderRequestAsync()
        {
            // Arrange
            var logger = LoggerMocker.GetLogger <SalesController>();
            var humanResourcesService = ServiceMocker.GetHumanResourcesService();
            var productionService     = ServiceMocker.GetProductionService();
            var salesService          = ServiceMocker.GetSalesService();

            using (var controller = new SalesController(logger, humanResourcesService, productionService, salesService))
            {
                // Act
                var response = await controller.GetCreateOrderRequestAsync() as ObjectResult;

                var value = response.Value as ISingleResponse <CreateOrderRequest>;

                // Assert
                Assert.False(value.DidError);
            }
        }
        public async Task TestGetOrdersByCustomerAsync()
        {
            // Arrange
            var logger = LoggerMocker.GetLogger <SalesController>();
            var humanResourcesService = ServiceMocker.GetHumanResourcesService();
            var productionService     = ServiceMocker.GetProductionService();
            var salesService          = ServiceMocker.GetSalesService();
            var customerID            = 1;

            using (var controller = new SalesController(logger, humanResourcesService, productionService, salesService))
            {
                // Act
                var response = await controller.GetOrdersAsync(customerID : customerID) as ObjectResult;

                var value = response.Value as IPagedResponse <OrderInfo>;

                // Assert
                Assert.False(value.DidError);
                Assert.True(value.Model.Where(item => item.CustomerID == customerID).Count() == value.Model.Count());
            }
        }