public void TransferFromMachine_UnitTest()
        {
            // Init
            Database database = new Database();
            TransferManager transferManager = new TransferManager(database);
            transferManager.buyStock("Snickers", 5, .25f);
            List<Product> listProduct = database.SelectAllProduct();

            Machine machine = new Machine("Milwaukee", "", "M101");
            database.Append(machine);
            transferManager.TransferToMachine(machine, listProduct);
            Assert.AreEqual(machine.getSingleQuantity("Snickers"), 5);
            List<Product> transferList = machine.selectAllProductByType("Snickers");

            // Action
            transferManager.TransferFromMachine(machine, transferList);

            // Assert
            Assert.AreEqual(database.SelectAllProduct().Count, 5);
            Assert.AreEqual(machine.getSingleQuantity("Snickers"), 0);

            List<Transactions> listTransactions = database.SelectAllTransactions();
            Assert.AreEqual(listTransactions.Count, 5);
            Assert.AreEqual(listTransactions[4].Amount, 1.25f);
        }
 public MachineStockAdjust(Database database, StartUp parent, Machine machine)
 {
     InitializeComponent();
     this.database = database;
     this.parent = parent;
     this.machine = machine;
     this.controller = new Controller(database);
 }
        public void TestEmployeeFullName()
        {
            Database database = new Database();
            Employee employee1 = new Employee("Jeff", "Test", "EIO987", "Brookfield");

            database.Append(employee1);
            
            List<Employee> EmployeeList = database.SelectAllEmployee();
            Assert.AreEqual("Jeff Test", EmployeeList[0].FullName);
        }
 public void Append_SelectAll_Product_UnitTest()
 {
     Database database = new Database();
     Product product1 = new Product("This is Not a Product", .25f);
     Product product2 = new Product("This is Not a Product2", .25f);
     database.Append(product1);
     database.Append(product2);
     List<Product> productList = database.SelectAllProduct();
     Assert.AreSame(productList[0], product1);
     Assert.AreSame(productList[1], product2);
 }
        public void MachineTestObjectAdded()
        {
            Database database = new Database();
            Machine machine1 = new Machine("Hartford", "Downtown", "M100");

            database.Append(machine1);

            List<Machine> MachineList = database.SelectAllMachine();

            Assert.AreEqual(machine1, MachineList[0]);
        }
        public void MachineNeedRestockInitial()
        {
            Database database = new Database();
            Machine machine1 = new Machine("Hartford", "Downtown", "M100");

            database.Append(machine1);

            List<Machine> MachineList = database.SelectAllMachine();

            Assert.AreEqual(true, MachineList[0].NeedRestock);
        }
 public void Append_SelectAll_Transaction_UnitTest()
 {
     Database database = new Database();
     Transactions transaction1 = new Transactions(1, DateTime.Now, "Checking", "Snickers", .50f);
     Transactions transaction2 = new Transactions(2, DateTime.Now, "Checking", "Snickers", .50f);
     database.Append(transaction1);
     database.Append(transaction2);
     List<Transactions> TransactionList = database.SelectAllTransactions();
     Assert.AreSame(TransactionList[0], transaction1);
     Assert.AreSame(TransactionList[1], transaction2);
 }
        public void TestEmployeeDateType()
        {
            Database database = new Database();
            Employee employee1 = new Employee("Jeff", "Test", "EIO987", "Brookfield");

            database.Append(employee1);

            DateTime today = DateTime.Today;

            List<Employee> EmployeeList = database.SelectAllEmployee();
            Assert.IsInstanceOfType(EmployeeList[0].DateStarted, typeof(DateTime));
        }
 public void Append_SelectAll_City_UnitTest()
 {
     Database database = new Database();
     City city1 = new City("Milwaukee", "WI", "MKE-WI");
     City city2 = new City("Waukesha", "WI", "WAU-WI");
     database.Append(city1);
     database.Append(city2);
     List<City> cityList = database.SelectAllCity();
     Assert.AreSame(cityList[0], city1);
     Assert.AreSame(cityList[1], city2);
     Assert.AreEqual(cityList[0].ID, "MKE-WI");
 }
 public void Append_SelectAll_Vehicle_UnitTest()
 {
     Database database = new Database();
     Vehicle vehicle1 = new Vehicle("Truck1", "Milwaukee", 1);
     Vehicle vehicle2 = new Vehicle("Truck2", "Milwaukee", 1);
     database.Append(vehicle1);
     database.Append(vehicle2);
     List<Vehicle> vehicleList = database.SelectAllVehicle();
     Assert.AreSame(vehicleList[0], vehicle1);
     Assert.AreSame(vehicleList[1], vehicle2);
     Assert.AreEqual(vehicleList[0].VehicleID, "Truck1");
 }
 public void Append_SelectAll_Employee_UnitTest()
 {
     Database database = new Database();
     Employee employee1 = new Employee("Bob", "Hope", "E1001", "Milwaukee");
     Employee employee2 = new Employee("Joe", "Schmoe", "E1002", "Waukesha");
     database.Append(employee1);
     database.Append(employee2);
     List<Employee> EmployeeList = database.SelectAllEmployee();
     Assert.AreSame(EmployeeList[0], employee1);
     Assert.AreSame(EmployeeList[1], employee2);
     Assert.AreEqual(EmployeeList[0].EmployeeID, "E1001");
 }
        public void TestEmployeeDateToday()
        {
            Database database = new Database();
            Employee employee1 = new Employee("Jeff", "Test", "EIO987", "Brookfield");

            database.Append(employee1);

            DateTime today = DateTime.Today;

            List<Employee> EmployeeList = database.SelectAllEmployee();
            Assert.AreEqual(today, EmployeeList[0].DateStarted);
        }
Example #13
0
        public void MachineCheckProductSingleQuantity()
        {
            Database database = new Database();
            Machine machine1 = new Machine("Hartford", "Downtown", "M100");

            Product product1 = new Product("coke", .75f);
            Product product2 = new Product("snickers", .75f);

            machine1.addProduct(product1);
            machine1.addProduct(product2);

            database.Append(machine1);

            List<Machine> MachineList = database.SelectAllMachine();

            Assert.AreEqual(1, MachineList[0].getSingleQuantity("coke"));
        }
        public void BuyStock_UnitTest()
        {
            // Init
            Database database = new Database();
            TransferManager transferManager = new TransferManager(database);

            // Action
            transferManager.buyStock("Snickers", 5, .25f);

            // Assert
            List<Product> listProduct = database.SelectAllProduct();
            List<Transactions> listTransactions = database.SelectAllTransactions();
            Assert.AreEqual(listProduct.Count, 5);
            Assert.AreEqual(listProduct[0].Name, "Snickers");
            Assert.AreEqual(listTransactions.Count, 1);
            Assert.AreEqual(listTransactions[0].Amount, -1.25f);
        }
Example #15
0
        public void MachineCheckProductTypeNames()
        {
            Database database = new Database();
            Machine machine1 = new Machine("Hartford", "Downtown", "M100");

            Product product1 = new Product("coke", .75f);
            Product product2 = new Product("snickers", .75f);

            machine1.addProduct(product1);
            machine1.addProduct(product2);
            List<string> expected = new List<string> { "coke", "snickers" };

            database.Append(machine1);

            List<Machine> MachineList = database.SelectAllMachine();

            CollectionAssert.AreEqual(expected, MachineList[0].getProductNames());
        }
Example #16
0
        public void MachineUpdateRetailPrice()
        {
            Database database = new Database();
            Machine machine1 = new Machine("Hartford", "Downtown", "M100");

            Product product1 = new Product("coke", .75f);
            Product product2 = new Product("snickers", .75f);

            machine1.addProduct(product1);
            machine1.addProduct(product2);
            machine1.updateRetailPrice("coke", 2.00f);
            float expected = 2.00f;

            database.Append(machine1);

            List<Machine> MachineList = database.SelectAllMachine();

            Assert.AreEqual(expected, product1.RetailPrice);
        }
        public void MachineSale_UnitTest()
        {
            // Init
            Database database = new Database();
            TransferManager transferManager = new TransferManager(database);
            Machine machine = new Machine("Milwaukee", "The Mall", "M101");
            database.Append(machine);
            transferManager.buyStock("Snickers", 5, .25f);
            List<Product> listProduct = database.SelectAllProduct();
            transferManager.TransferToMachine(machine, listProduct);
            List<Product> listProductBefore = machine.selectAllProductByType("Snickers");
            int startingCount = listProductBefore.Count;

            // Action
            transferManager.machineSale(machine, listProductBefore[0]);

            // Assert
            List<Product> listProductAfter = machine.selectAllProductByType("Snickers");
            List<Transactions> listTransactionsAfter = database.SelectAllTransactions();
            int endingCount = listProductAfter.Count;
            int transactionCount = listTransactionsAfter.Count;
            Assert.AreEqual(startingCount - 1, endingCount);
            Assert.AreEqual(5, transactionCount);
        }
Example #18
0
 public AddEmployee(Database database, StartUp parent)
 {
     InitializeComponent();
     this.database = database;
     this.parent = parent;
 }
Example #19
0
 public Controller(Database database)
 {
     this.database = database;
     this.transferManager = new TransferManager(database);
 }
 public AddItemByMachine(Database database, StartUp parent)
 {
     InitializeComponent();
     this.database = database;
     this.parent = parent;
 }
 public ChartSalesByProduct(Database database)
 {
     InitializeComponent();
     this.database = database;
 }
 public TransferManager(Database database)
 {
     this.database = database;
 }
Example #23
0
 public AddProduct(Database database, StartUp parent)
 {
     InitializeComponent();
     this.database = database;
     this.parent = parent;
 }
        public void TransferToMachine_UnitTest()
        {
            // Init
            Database database = new Database();
            TransferManager transferManager = new TransferManager(database);
            transferManager.buyStock("Snickers", 5, .25f);
            List<Product> listProduct = database.SelectAllProduct();

            Machine machine = new Machine("Milwaukee", "", "M101");

            // Action
            transferManager.TransferToMachine(machine, listProduct);

            // Assert
            int SnickerQuantity = machine.getSingleQuantity("Snickers");
            int AllQuantity = machine.getAllQuantity();
            listProduct = database.SelectAllProduct();
            List<Transactions> listTransactions = database.SelectAllTransactions();
            Assert.AreEqual(listProduct.Count, 0);
            Assert.AreEqual(SnickerQuantity, 5);
            Assert.AreEqual(AllQuantity, 5);
            Assert.AreEqual(listTransactions.Count, 3);
            Assert.AreEqual(listTransactions[2].Amount, -1.25);
        }