Example #1
0
        public void IssueDefault()
        {
            VehicleIssue vi1  = new VehicleIssue();
            var          type = vi1.GetType();

            Assert.IsInstanceOfType(vi1, type);
        }
Example #2
0
        public void IssueToString()
        {
            DateTime     issueDate = new DateTime(2018, 1, 1);
            Vehicle      v         = new Vehicle();
            VehicleIssue vi        = new VehicleIssue(issueDate, "test", v);

            Assert.AreEqual("Report #0", vi.ToString());
        }
        /// <summary>
        /// The Deny method will remove the issue if the issue is deemed
        /// invalid, and return the cars state to not damaged
        /// </summary>
        /// <param name="vi"></param>
        public static void Deny(VehicleIssue vi)
        {
            Vehicle v1 = VehicleControl.FindVehicle(vi.VehicleID.ToString());

            v1.IsDamaged = false;
            DBController.Delete(vi);
            DBController.Save(v1, DBObject.SaveTypes.Update);
        }
 /// <summary>
 /// The ReportList_SelectedINdexChanged method will update the currently
 /// selected vehicle issue and display its properties.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void reportList_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (reportList.SelectedItem != null)
     {
         selected           = (VehicleIssue)reportList.SelectedItem;
         reportDetails.Text = selected.Issue;
     }
 }
        /// <summary>
        /// The Fix method will update the vehicle in questions isDamaged
        /// to represent the car is fixed, and update the issue as being
        /// fixed.
        /// </summary>
        /// <param name="vi"></param>
        public static void Fix(VehicleIssue vi)
        {
            Vehicle v1 = VehicleControl.FindVehicle(vi.VehicleID.ToString());

            v1.IsDamaged = false;
            vi.IsFixed   = true;
            DBController.Save(vi, DBObject.SaveTypes.Update);
            DBController.Save(v1, DBObject.SaveTypes.Update);
        }
Example #6
0
        public void CreateIssue()
        {
            DateTime     issueDate = new DateTime(2018, 1, 1);
            string       Issue     = "The car broke down and won't start!";
            Vehicle      v1        = new Vehicle();
            VehicleIssue vi1       = new VehicleIssue(issueDate, Issue, v1);

            Assert.AreEqual(vi1.IssueDate, issueDate);
            Assert.AreEqual(vi1.Issue, Issue);
            Assert.AreEqual(vi1.VehicleID, v1.VehicleID);
        }
Example #7
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);
        }
Example #8
0
        public void AddVehicleIssue()
        {
            DateTime     issueDate = new DateTime(2018, 1, 1);
            string       Issue     = "The car broke down and won't start!";
            Vehicle      v1        = new Vehicle();
            VehicleIssue vI1       = new VehicleIssue(issueDate, Issue, v1);

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

            Assert.AreEqual(vI1.PrimaryKey, vI2.PrimaryKey);
        }
 public static bool AddIssue(VehicleIssue vI)
 {
     try
     {
         DBController.Save(vI, DBObject.SaveTypes.Insert);
     }
     catch (Exception e)
     {
         return(false);
     }
     return(true);
 }
 /// <summary>
 /// The method will use the VehicleIssue Object, and insert the
 /// VehicleIssue into the table, as well as update the vehicle
 /// attribute, isDamaged to signify the car is in need of repair
 /// </summary>
 /// <param name="vI"></param>
 /// <returns></returns>
 public static bool AddIssue(VehicleIssue vI)
 {
     try
     {
         Vehicle v1 = VehicleControl.FindVehicle(vI.VehicleID.ToString());
         v1.IsDamaged = true;
         DBController.Save(vI, DBObject.SaveTypes.Insert);
         DBController.Save(v1, DBObject.SaveTypes.Update);
     }
     catch (Exception e)
     {
         return(false);
     }
     return(true);
 }
Example #11
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);
        }
Example #12
0
        /// <summary>
        /// The sendButton once pressed will generate and send a vehicle issue
        /// to the database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void sendButton_Click(object sender, System.EventArgs e)
        {
            Vehicle  v1        = VehicleControl.FindVehicle(r1.VehicleID.ToString());
            DateTime issueDate = problemDate.Value.Date;
            string   Issue     = descriptionTextBox.Text;

            try
            {
                VehicleIssue vehicleIssue = new VehicleIssue(issueDate.Date, Issue, v1);
                if (VehicleIssueControl.AddIssue(vehicleIssue))
                {
                    messageLabel.Text = "The report has been sent. Thank you for your patience.";
                    descriptionTextBox.Clear();
                    messageLabel.Visible = true;
                }
            }
            catch (Exception)
            {
            }
        }