public void ResupplyAndReorderReadAndWrite() { string path = "../../../SimplyWriteData.json"; JsonFilePersist persist = new JsonFilePersist(path); CStore store = persist.ReadStoreData(); List <CProduct> supply = new List <CProduct> { new CProduct("111", "Banana", "Produce", 0.5, 10), new CProduct("222", "orange", "Produce", 0.88, 10), new CProduct("333", "Rocket", "Transport", 1000000, 15) }; store.AddProducts(supply); CCustomer customer = new CCustomer("127137147", "Adam", "Savage", "4801111111"); List <CProduct> p = new List <CProduct> { new CProduct("111", "Banana", "Produce", 0.5, 1), new CProduct("222", "orange", "Produce", 0.88, 1) }; COrder order = new COrder(store, customer, DateTime.Today, 100, p); customer.PlaceOrder(store, order); persist.WriteStoreData(store); foreach (var pair in store.Inventory) { Assert.Equal(15, pair.Value.Quantity); } }
public void SimplyReadData() { string path = "../../../SimplyWriteData.json"; JsonFilePersist persist = new JsonFilePersist(path); CStore store = persist.ReadStoreData(); foreach (var product in store.CustomerDict["123123121"].OrderHistory[0].ProductList) { Assert.Equal(4, product.Quantity); } }