Exemple #1
0
 public Task <int> SavePriceCatalogAsync(PriceCatalog data)
 {
     if (data.ID != 0)
     {
         return(_database.UpdateAsync(data));
     }
     else
     {
         return(_database.InsertAsync(data));
     }
 }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        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);
        }
Exemple #7
0
        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
            }
        }
Exemple #8
0
        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);
        }
Exemple #9
0
        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);
        }
Exemple #11
0
        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);
        }
Exemple #12
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");
        }
Exemple #13
0
 public Task <int> Delete_PriceCatalogItem_Async(PriceCatalog data)
 {
     return(_database.DeleteAsync(data));
 }