public Task <int> SavePriceCatalogAsync(PriceCatalog data) { if (data.ID != 0) { return(_database.UpdateAsync(data)); } else { return(_database.InsertAsync(data)); } }
public void PriceCatalogTest() { Dictionary <string, decimal> sample = new Dictionary <string, decimal>() { { "APPLE", 0.50m }, { "ORANGE", 0.70m }, { "BANANA", 0.82m } }; PriceCatalog test = new PriceCatalog(sample); Assert.IsNotNull(test); }
public void SetItemPriceTest() { Dictionary <string, decimal> sample = new Dictionary <string, decimal>() { { "APPLE", 0.50m }, { "ORANGE", 0.70m }, { "BANANA", 0.82m } }; PriceCatalog test = new PriceCatalog(sample); test.SetItemPrice("APPLE", 0.60m); Assert.AreEqual(test.GetItemPrice("APPLE"), 0.60m); }
public void ReceiptTest() { Dictionary <string, decimal> sample = new Dictionary <string, decimal>() { { "APPLE", 0.50m }, { "ORANGE", 0.70m }, { "BANANA", 0.82m } }; PriceCatalog catalog = new PriceCatalog(sample); Receipt model = new Receipt(catalog); Assert.IsNotNull(model); }
public void CheckStockTest() { Dictionary <string, decimal> sample = new Dictionary <string, decimal>() { { "APPLE", 0.50m }, { "ORANGE", 0.70m }, { "BANANA", 0.82m } }; PriceCatalog test = new PriceCatalog(sample); Assert.AreEqual(test.CheckStock("APPLE"), true); Assert.AreEqual(true, test.CheckStock("APPLE")); Assert.AreEqual(false, test.CheckStock("PINEAPPLE")); Assert.AreEqual(test.CheckStock("PINEAPPLE"), false); }
public void ReceiptControllerTest() { Dictionary <string, decimal> sample = new Dictionary <string, decimal>() { { "APPLE", 0.50m }, { "ORANGE", 0.70m }, { "BANANA", 0.82m } }; PriceCatalog catalog = new PriceCatalog(sample); Receipt model = new Receipt(catalog); ReceiptView view = new ReceiptView(); ReceiptController controller = new ReceiptController(view, model); Assert.IsNotNull(controller); }
static void Main(string[] args) { while (true) { // Read in the item catalog for all items and associated promotions in the given file "Catalog.txt" PriceCatalog.ReadPriceCatalog(); // Start the interaction with the user UserInteraction.Start(); // Print the recipt, calculate cost, clear data Checkout.Finish(); // Repeat } }
public void CheckReceiptItemTestWithAddOrUpdate() { Dictionary <string, decimal> sample = new Dictionary <string, decimal>() { { "APPLE", 0.50m }, { "ORANGE", 0.70m }, { "BANANA", 0.82m } }; PriceCatalog catalog = new PriceCatalog(sample); Receipt model = new Receipt(catalog); model.AddOrUpdateItem("APPLE"); model.AddOrUpdateItem("ORANGE"); Assert.AreEqual(model.CheckReceiptItem("APPLE"), true); Assert.AreEqual(model.CheckReceiptItem("ApPLE"), true); }
public void GetTotalTest() { Dictionary <string, decimal> sample = new Dictionary <string, decimal>() { { "APPLE", 0.50m }, { "ORANGE", 0.70m }, { "BANANA", 0.82m } }; PriceCatalog catalog = new PriceCatalog(sample); Receipt model = new Receipt(catalog); model.AddOrUpdateItem("APPLE"); model.AddOrUpdateItem("APPLE"); Assert.AreEqual(model.GetTotal(), 1.00m); model.AddOrUpdateItem("ORANGE"); Assert.AreEqual(model.GetTotal(), 1.70m); }
public void GetPriceOfReceiptItemTest() { Dictionary <string, decimal> sample = new Dictionary <string, decimal>() { { "APPLE", 0.50m }, { "ORANGE", 0.70m }, { "BANANA", 0.82m } }; PriceCatalog catalog = new PriceCatalog(sample); ReceiptView view = new ReceiptView(); Receipt model = new Receipt(catalog); model.AddOrUpdateItem("APPLE"); ReceiptController controller = new ReceiptController(view, model); Assert.AreEqual(controller.GetPriceOfReceiptItem("APPLE"), 0.50m); }
public void GetQuantityOfItemTest() { Dictionary <string, decimal> sample = new Dictionary <string, decimal>() { { "APPLE", 0.50m }, { "ORANGE", 0.70m }, { "BANANA", 0.82m } }; PriceCatalog catalog = new PriceCatalog(sample); Receipt model = new Receipt(catalog); model.AddOrUpdateItem("APPLE"); model.AddOrUpdateItem("APPLE"); model.AddOrUpdateItem("ORANGE"); Assert.AreEqual(model.GetQuantityOfItem("APPLE"), 2); Assert.AreEqual(model.GetQuantityOfItem("ApPLE"), 2); Assert.AreEqual(model.GetQuantityOfItem("Orange"), 1); Assert.AreEqual(model.GetQuantityOfItem("Orange?"), 0); }
public void GetReceiptItemNamesTest() { Dictionary <string, decimal> sample = new Dictionary <string, decimal>() { { "APPLE", 0.50m }, { "ORANGE", 0.70m }, { "BANANA", 0.82m } }; PriceCatalog catalog = new PriceCatalog(sample); Receipt model = new Receipt(catalog); model.AddOrUpdateItem("APPLE"); model.AddOrUpdateItem("APPLE"); model.AddOrUpdateItem("ORANGE"); List <string> testOut = model.GetReceiptItemNames(); Assert.IsNotNull(testOut); Assert.AreEqual(testOut[0], "APPLE"); }
public Task <int> Delete_PriceCatalogItem_Async(PriceCatalog data) { return(_database.DeleteAsync(data)); }