Exemplo n.º 1
0
        public void Stock_Calculator_Tests(int currentQuantityToFulfill, int stockAvailableToFulfill, int expected)
        {
            // Arrange
            var stockCalculatorService = new StockCalculatorService();

            // Act
            var result = stockCalculatorService.QuantityLeftToFulfill(currentQuantityToFulfill, stockAvailableToFulfill);

            // Assert
            Assert.Equal(expected, result);
        }
        public void ProductFulfillmentServiceTests_Tests()
        {
            // Arrange
            var supplierService = new SupplierService();
            var supplierShippingCostCalculator  = new SupplierShippingCostCalculator();
            var stockCalculatorService          = new StockCalculatorService();
            var purchaseOrderFulfillmentService = new PurchaseOrderFulfillmentService(stockCalculatorService);

            var productFulfillmentService = new ProductFulfillmentService(supplierService, supplierShippingCostCalculator, purchaseOrderFulfillmentService);

            // Act
            var result = productFulfillmentService.GetPurchaseOrderItems(new TestData().Create());

            // Assert
            Assert.NotEmpty(result);
            Assert.All(result, item => Assert.False(item.SelfFulfillment));
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            // Our data store
            var purchaseRequirements = new TestData().Create();

            // Dependencies at top of composition root
            var supplierService = new SupplierService();
            var supplierShippingCostCalculator  = new SupplierShippingCostCalculator();
            var stockCalculatorService          = new StockCalculatorService();
            var purchaseOrderFulfillmentService = new PurchaseOrderFulfillmentService(stockCalculatorService);

            var productFulfillmentService     = new ProductFulfillmentService(supplierService, supplierShippingCostCalculator, purchaseOrderFulfillmentService);
            var serviceTypeFulfillmentService = new ServiceTypeFulfillmentService();

            // Optimize and generate purchase orders for suppliers to fulfill
            var purchaseOptimizer = new PurchaseOptimizer(new List <IFulfillmentService>()
            {
                serviceTypeFulfillmentService, productFulfillmentService
            });

            purchaseOptimizer.Optimize(purchaseRequirements);

            Console.Read();
        }