public void Run() { OnlineShopping onlineShop1 = new OnlineShopping(new TwoYuanShopCounter(), new Holiday88Discounter()); System.Console.WriteLine(onlineShop1.ShowPriceAfterDiscount("cat")); OnlineShopping onlineShop2 = new OnlineShopping(new TwoYuanShopCounter(), new Double11Discounter()); System.Console.WriteLine(onlineShop2.ShowPriceAfterDiscount("cat")); OnlineShopping onlineShop3 = new ShoppingWithHuaBei(new TwoYuanShopCounter(), new Double11Discounter()); System.Console.WriteLine(onlineShop3.ShowPriceAfterDiscount("cat")); }
public void ApproveSwitchStore() { /* * 1. Fix the setup of this test so that it can run * 2. Use Approvals to verify the OnlineShopping instance * 3. Check the received file, modify any necessary ToString methods until you are happy with the output * 4. Approve the new output * 5. Re-run the test to make sure it is now green * 6. Convert your approvals test into a combination approvals test. Use a single combination initially * 7. Run the test and inspect the output * 8. Add more combinations until all branches are fully covered * 9. Test mutations by modifying parts of the production code. Do your tests fail when you break production code? */ Session session = null; OnlineShopping onlineShopping = new OnlineShopping(session); Store storeToSwitchTo = null; onlineShopping.SwitchStore(storeToSwitchTo); }
private object DoSwitchStore(string deliveryType, string deliveryAddress, Store storeToSwitchTo, bool nullCart, bool nullDeliveryInfo) { var deliveryInfo = new DeliveryInformation(deliveryType, _nordstan, 60) { DeliveryAddress = deliveryAddress }; if (nullDeliveryInfo) { deliveryInfo = null; // if deliveryInfo is null then address is meaningless so skip this combination in the tests if (deliveryAddress != null) { return(null); } } Cart cart = new Cart(); cart.AddItem(_cherryBloom); cart.AddItem(_blusherBrush); cart.AddItem(_masterclass); cart.AddItem(_makeoverNordstan); if (nullCart) { cart = null; if (deliveryInfo != null) { return(null); } } Session session = new NonSavingSession(); session.Put("STORE", _nordstan); session.Put("DELIVERY_INFO", deliveryInfo); session.Put("CART", cart); var shopping = new OnlineShopping(session); shopping.SwitchStore(storeToSwitchTo); return(shopping.ToString()); }