Exemple #1
0
 /// <summary>
 /// Richard Carroll
 /// Created: 3/1/19
 ///
 /// Runs the validation method before attempting to insert a Vehicle into the
 /// Database, and returns the result.
 /// </summary>
 private void BtnSave_Click(object sender, RoutedEventArgs e)
 {
     if (cboGuestID.SelectedIndex != -1)
     {
         _guestVehicle = new GuestVehicle
         {
             GuestID         = _guests[cboGuestID.SelectedIndex].GuestID,
             Make            = txtMake.Text,
             Model           = txtModel.Text,
             PlateNumber     = txtPlateNum.Text,
             Color           = txtColor.Text,
             ParkingLocation = txtParkingLocation.Text
         };
     }
     else
     {
         MessageBox.Show("Please select a guest.");
     }
     if (validateFields())
     {
         try
         {
             if (_guestVehicleManager.CreateGuestVehicle(_guestVehicle))
             {
                 MessageBox.Show("Successfully Added Guest Vehicle");
                 clearFields();
                 this.DialogResult = true;
                 this.Close();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("Failed to Add Guest Vehicle: \n" + ex.Message);
         }
     }
 }
        public void TestCreateGuestVehicleValidInput()
        {
            guestVehicle = new GuestVehicle()
            {
                GuestID         = 100001,
                Make            = "Honda",
                Model           = "Caravan",
                PlateNumber     = "123 ABC",
                Color           = "White",
                ParkingLocation = "Out Back"
            };
            guestVehicleManager.CreateGuestVehicle(guestVehicle);
            retrievedVehicles = guestVehicleAccessor.SelectAllGuestVehicles();

            Assert.IsNotNull(retrievedVehicles.Find(v => v.GuestID == guestVehicle.GuestID &&
                                                    v.Make == guestVehicle.Make && v.Model == guestVehicle.Model &&
                                                    v.PlateNumber == guestVehicle.PlateNumber && v.Color == guestVehicle.Color &&
                                                    v.ParkingLocation == guestVehicle.ParkingLocation));
        }