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)); }
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(); }