static void Main(string[] args)
        {
            // Instantiate the dependencies
            IInventorySource   inventorySource   = new InventoryFileDAL("vendingmachine.csv");
            ITransactionLogger transactionLogger = new TransactionFileLog("transactions.txt");

            // IInventorySource inventorySource = new InventorySqlDAL("connectionstring");

            VendingMachine vm;

            try
            {
                // Inject the dependency into the class using the constructor
                vm = new VendingMachine(inventorySource, transactionLogger);
            }
            catch
            {
                Console.WriteLine();
                Console.WriteLine("An error occurred starting the vending machine. The program is going to exit.");
                return;
            }

            // Start the CLI and run the menu
            VendingMachineCLI cli = new VendingMachineCLI(vm);

            cli.Run();
        }
        public void TestMethod1()
        {
            InventoryFileDAL test = new InventoryFileDAL();
            Dictionary <string, List <VendingMachineItem> > line = test.GetInventory();

            Assert.AreEqual(16, line.Count);
        }
        public void HasKeyA1()
        {
            string filePath;
            string currentDirectory = Directory.GetCurrentDirectory();

            filePath = Path.Combine(currentDirectory, "vendingmachineinventory.txt");
            InventoryFileDAL testyThing = new InventoryFileDAL(filePath);

            Assert.AreEqual(true, testyThing.GetInventory().ContainsKey("A1"));
        }
        public void TotalItemsShouldBe16()
        {
            string filePath;
            string currentDirectory = Directory.GetCurrentDirectory();

            filePath = Path.Combine(currentDirectory, "vendingmachineinventory.txt");
            InventoryFileDAL testyThing = new InventoryFileDAL(filePath);

            Assert.AreEqual(16, testyThing.GetInventory().Count);
        }
Пример #5
0
        public void GetQtyRemaingOnNewInventoryShouldReturn5()
        {
            string filePath;
            string currentDirectory = Directory.GetCurrentDirectory();

            filePath = Path.Combine(currentDirectory, "vendingmachineinventory.txt");

            InventoryFileDAL testyThing = new InventoryFileDAL(filePath);

            VendingMachine testMachine = new VendingMachine();

            Assert.AreEqual(5, testMachine.GetQuantityRemaining("A1"));
        }
Пример #6
0
        static void Main(string[] args)
        {
            const string localConnectionString = "Data Source=localhost\\sqlexpress;Initial Catalog=VendingMachine;Integrated Security=True";

            // Instantiate the dependencies

            IInventorySource   inventorySource;
            ITransactionLogger transactionLogger;

            string mode = Properties.Settings.Default.DataSource;

            if (mode == "file")
            {
                inventorySource   = new InventoryFileDAL("vendingmachine.csv");
                transactionLogger = new TransactionFileLog("transactions.txt");
            }
            else
            {
                inventorySource   = new InventorySqlDAL(localConnectionString);
                transactionLogger = new TransactionFileSqlLog(localConnectionString);
            }

            VendingMachine vm;

            try
            {
                // Inject the dependency into the class using the constructor
                vm = new VendingMachine(inventorySource, transactionLogger);
            }
            catch
            {
                Console.WriteLine();
                Console.WriteLine("An error occurred starting the vending machine. The program is going to exit.");
                return;
            }

            // Start the CLI and run the menu
            VendingMachineCLI cli = new VendingMachineCLI(vm);

            cli.Run();
        }