Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public void FixTest()
        {
            DateTime     issueDate = new DateTime(2018, 1, 1);
            string       Issue     = "The car broke down and won't start!";
            Vehicle      v1        = VehicleControl.GetAllVehicles().FirstOrDefault();
            VehicleIssue vI1       = new VehicleIssue(issueDate, Issue, v1);

            Assert.IsFalse(vI1.IsFixed);
            VehicleIssueControl.Fix(vI1);
            Assert.IsTrue(vI1.IsFixed);
        }
Ejemplo n.º 3
0
        public void PurchaseControlDataTest()
        {
            string   location   = "here";
            DateTime dateEx     = new DateTime(2001, 1, 1);
            Vehicle  purchasedV = VehicleControl.GetAllVehicles().FirstOrDefault();

            PurchaseControl.PickUpLocation  = "here";
            PurchaseControl.StartDate       = dateEx;
            PurchaseControl.SelectedVehicle = purchasedV;
            Assert.AreEqual(PurchaseControl.PickUpLocation, location);
            Assert.AreEqual(PurchaseControl.SelectedVehicle, purchasedV);
            Assert.AreEqual(PurchaseControl.StartDate, dateEx);
        }
Ejemplo n.º 4
0
        public void DenyTest()
        {
            DateTime     issueDate = new DateTime(2018, 1, 1);
            string       Issue     = "The car broke down and won't start!";
            Vehicle      v1        = VehicleControl.GetAllVehicles().FirstOrDefault();
            VehicleIssue vI1       = new VehicleIssue(issueDate, Issue, v1);

            VehicleIssueControl.AddIssue(vI1);
            VehicleIssue vI2 = DBController.GetByPrimaryKey <VehicleIssue>(vI1.PrimaryKey);

            Assert.AreEqual(vI1.PrimaryKey, vI2.PrimaryKey);
            VehicleIssueControl.Deny(vI1);
            VehicleIssue vI3 = DBController.GetByPrimaryKey <VehicleIssue>(vI1.PrimaryKey);

            Assert.IsNull(vI3);
        }
Ejemplo n.º 5
0
        public void ModifyCarTest()
        {
            Vehicle v = new Vehicle();

            DBController.Save(v, DBObject.SaveTypes.Insert);
            v.Color = "chartreuse";
            VehicleControl.ModifyVehicle(v);
            Vehicle v2 = VehicleControl.GetAllVehicles().Where(car => car.Color == "chartreuse").FirstOrDefault();

            Assert.IsNotNull(v2);
            Assert.AreEqual(v2.Color, "chartreuse");
            if (v2.Color == "chartreuse")
            {
                DBController.Delete(v);
            }
        }
Ejemplo n.º 6
0
        public void FilterCarTest()
        {
            Vehicle        v          = VehicleControl.GetAllVehicles().FirstOrDefault();
            Vehicle        vR         = VehicleControl.GetAllVehicles().Where(vehicle => vehicle.IsRented).FirstOrDefault();
            string         cartype    = v.Type;
            string         carcolor   = v.Color;
            string         carmake    = v.Make;
            int            caryear1   = 0;
            int            caryear2   = 2019;
            DateTime       startDate  = new DateTime(2018, 1, 1);
            DateTime       endDate    = new DateTime(2018, 1, 2);
            DateTime       startDate2 = new DateTime(2018, 5, 1);
            DateTime       endDate2   = new DateTime(2018, 5, 2);
            List <Vehicle> lv         = VehicleControl.FilterCar(vR.Type, vR.Color, vR.Make, vR.VehicleYear, vR.VehicleYear, vR.RightHandControlled, vR.ManualTransmission, vR.CurrentLocation, startDate2, endDate2);

            Assert.IsNotNull(lv);
            lv = VehicleControl.FilterCar(cartype, carcolor, carmake, caryear1, caryear2, false, false, "Madison", startDate, endDate);
            Assert.IsNotNull(lv);
            Vehicle v2 = lv.Where(car => car.Type == cartype && car.Color == carcolor && car.VehicleYear >= caryear1 && car.VehicleYear <= caryear2).FirstOrDefault();

            Assert.IsNotNull(v2);
            lv = VehicleControl.FilterCar(null, null, null, 1900, 2020, false, false, null, startDate, endDate);
            Assert.IsNotNull(lv);
        }