public void Create_Product() { using (var context = new StoreContext()) { var factory = new Factory(new ShippingMethodRepository(context)); var products = new ProductRepository(context); var newProduct = factory.CreateProduct("NEW", "New Product"); var option1 = factory.CreateProductOption(sku: "NEWPUSM", colour: "PURPLE", size: "SMALL", price: 18.00M, priceWas: null, stockLevel: 10); var option2 = factory.CreateProductOption(sku: "NEWPULG", colour: "PURPLE", size: "LARGE", price: 20.00M, priceWas: null, stockLevel: 10); newProduct.AddOption(option1); newProduct.AddOption(option2); products.Save(newProduct); var product = products.Load(3); Assert.That(product.SKU == "NEW"); Assert.That(product.Options.Count() == 2); } }
public void Create_Order() { using (var context = new StoreContext()) { var factory = new Factory(new ShippingMethodRepository(context)); var orders = new OrderRepository(context); var products = new ProductRepository(context); var newOrder = factory.CreateOrder(); var product = products.Load(2); var option = product.Options.First(o => o.SKU == "P2ORLA"); newOrder.AddItem(option, 1); orders.Save(newOrder); var order = orders.Load(1); Assert.That(order.Lines.Count() == 1); Assert.That(order.Total == 16.00M); } }