Beispiel #1
0
        public async Task TestCreateOrderAsync()
        {
            // Arrange
            var logger       = LogHelper.GetLogger <SalesController>();
            var salesService = ServiceMocker.GetSalesService(nameof(TestCreateOrderAsync));
            var controller   = new SalesController(logger, salesService);
            var model        = new OrderRequestModel
            {
                CustomerID       = 1,
                PaymentMethodID  = new Guid("7671A4F7-A735-4CB7-AAB4-CF47AE20171D"),
                Comments         = "Order from unit tests",
                CreationUser     = "******",
                CreationDateTime = DateTime.Now,
                Details          = new List <OrderDetailRequestModel>
                {
                    new OrderDetailRequestModel
                    {
                        ProductID   = 1,
                        ProductName = "The King of Fighters XIV",
                        Quantity    = 1,
                    }
                }
            };

            // Act
            var response = await controller.CreateOrderAsync(model) as ObjectResult;

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

            controller.Dispose();

            // Assert
            Assert.False(value.DidError);
            Assert.True(value.Model.OrderID.HasValue);
        }
Beispiel #2
0
        public async Task TestGetOrdersAsync()
        {
            // Arrange
            var logger       = LogHelper.GetLogger <SalesController>();
            var salesService = ServiceMocker.GetSalesService(nameof(TestGetOrdersAsync));
            var controller   = new SalesController(logger, salesService);

            // Act
            var response = await controller.GetOrdersAsync() as ObjectResult;

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

            controller.Dispose();

            // Assert
            Assert.False(value.DidError);
        }
        public async Task GetProductsTestAsync()
        {
            // Arrange
            var logger            = LogHelper.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);
            }
        }
Beispiel #4
0
        public async Task TestGetProductsTestAsync()
        {
            // Arrange
            var logger            = LogHelper.GetLogger <ProductionController>();
            var productionService = ServiceMocker.GetProductionService(nameof(TestGetProductsTestAsync));
            var controller        = new ProductionController(logger, productionService);

            // Act
            var response = await controller.GetProductsAsync() as ObjectResult;

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

            controller.Dispose();

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

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

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

                // Assert
                Assert.False(value.DidError);
            }
        }
        public async Task TestGetCreateOrderRequestAsync()
        {
            // Arrange
            var logger       = LogHelper.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);
            }
        }
Beispiel #7
0
        public async Task TestGetOrdersByEmployeeAsync()
        {
            // Arrange
            var logger       = LogHelper.GetLogger <SalesController>();
            var salesService = ServiceMocker.GetSalesService(nameof(TestGetOrdersByEmployeeAsync));
            var controller   = new SalesController(logger, salesService);
            var employeeID   = 1;

            // Act
            var response = await controller.GetOrdersAsync(employeeID : employeeID) as ObjectResult;

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

            controller.Dispose();

            // Assert
            Assert.False(value.DidError);
            Assert.True(value.Model.Where(item => item.EmployeeID == employeeID).Count() == value.Model.Count());
        }
        public async Task TestGetOrdersByCustomerAsync()
        {
            // Arrange
            var logger       = LogHelper.GetLogger <SalesController>();
            var salesService = ServiceMocker.GetSalesService();
            var customerID   = 1;

            using (var controller = new SalesController(logger, 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());
            }
        }
Beispiel #9
0
        public async Task TestGetInventoryByProductTestAsync()
        {
            // Arrange
            var logger            = LogHelper.GetLogger <ProductionController>();
            var productionService = ServiceMocker.GetProductionService(nameof(TestGetInventoryByProductTestAsync));
            var controller        = new ProductionController(logger, productionService);
            var productID         = 1;
            var warehouseID       = "W0001";

            // Act
            var response = await controller.GetProductInventoryAsync(productID, warehouseID) as ObjectResult;

            var value = response.Value as IListResponse <ProductInventory>;

            controller.Dispose();

            // Assert
            Assert.False(value.DidError);
            Assert.True(value.Model.Count() > 0);
        }