Example #1
0
        public void AddPurchaseTest()
        {
            Vehicle v = new Vehicle("type", "color", 100, "model", "make", true, true, 10, "here");

            DBController.Save(v, DBObject.SaveTypes.Insert);
            DateTime startDate1 = new DateTime(2018, 1, 1);
            DateTime endDate1   = new DateTime(2018, 1, 2);
            Vehicle  v2         = VehicleControl.FilterCar("type", "color", "make", 99, 101, true, true, "here", startDate1, endDate1).FirstOrDefault();

            Assert.IsNotNull(v2);
            Customer c1 = new Customer("John", "Doe", "username", "password");

            DBController.Save(c1, DBObject.SaveTypes.Insert);
            DateTime startDate = new DateTime(2018, 1, 1);
            DateTime endDate   = new DateTime(2018, 1, 2);
            Purchase p1        = new Purchase(startDate, "here", v2, c1);

            PurchaseControl.AddPurchase(p1);
            Vehicle v3 = VehicleControl.FilterCar("type", "color", "make", 99, 101, true, true, "here", startDate, endDate).FirstOrDefault();

            Assert.IsNull(v3);
            Vehicle v4 = VehicleControl.GetAllVehicles().Where(vehicle => vehicle.VehicleID == p1.VehicleID).FirstOrDefault();

            Assert.IsTrue(v4.IsRented);
        }
Example #2
0
        /// <summary>
        /// Once the purchase button is pressed, the information is stored in
        /// the purchase table, and the user is notified of their purchase order
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buyButton_Click(object sender, System.EventArgs e)
        {
            _purchaseToPayFor.Location     = _vehicleToPayFor.CurrentLocation;
            _purchaseToPayFor.PurchaseDate = _purchaseToPayFor.PurchaseDate.Date;
            PurchaseControl.AddPurchase(_purchaseToPayFor);
            ConfirmationPage c = new ConfirmationPage(_purchaseToPayFor)
            {
                MdiParent       = MdiParent,
                ClientSize      = new Size(),
                FormBorderStyle = FormBorderStyle.None,
                Dock            = DockStyle.Fill
            };

            WindowState = FormWindowState.Normal;
            c.Show();
        }
Example #3
0
        public void FindPurchaseTest()
        {
            Vehicle v1 = new Vehicle();

            VehicleControl.AddVehicle(v1);
            int      key = v1.PrimaryKey;
            Purchase p1  = PurchaseControl.FindPurchase(key);

            Assert.IsNull(p1);
            p1           = new Purchase();
            p1.VehicleID = key;
            Customer c1 = DBController.GetAllRecords <Customer>().FirstOrDefault();

            p1.CustomerID = c1.PrimaryKey;
            PurchaseControl.AddPurchase(p1);
            Purchase p2 = PurchaseControl.FindPurchase(key);

            Assert.IsNotNull(p2);
        }