Example #1
0
        static void Main(string[] args)
        {
            var setup   = new SetUpService();
            var catalog = setup.CreateCatalogue();

            var scanService  = new ScanService(catalog);
            var totalService = new TotalUpService(catalog);

            Console.WriteLine("Checkout service");
            Console.WriteLine("Please enter the code for each item and press enter. Entering 'DONE' will return the total");

            var checkOut = false;

            while (!checkOut)
            {
                var line = Console.ReadLine();
                if (line == "DONE")
                {
                    checkOut = true;
                    Console.WriteLine("Total: " + totalService.TotalUp(scanService.ScannedItems).ToString());
                    Console.ReadLine();
                }
                else
                {
                    try
                    {
                        scanService.Scan(line);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
        }
        public void ScanMultipleOfSameItemWithNoDeal()
        {
            var scannedItems = new List <Product>()
            {
                new Product("T23", 1.00m, "Tea"),
                new Product("T23", 1.00m, "Tea"),
                new Product("T23", 1.00m, "Tea")
            };

            Assert.AreEqual(TotalService.TotalUp(scannedItems), 3.00m);
        }