public void TestUpdateReservationValidInput() { //Arrange Reservation newReservation = new Reservation(); setReservations(_reservations[0], newReservation); string newNotes = "This test is updating the notes in TestUpdateReservationValidInput()"; newReservation.Notes = newNotes; //Act _reservationManager.EditReservation(_reservations[0], newReservation); //Assert _reservations = _reservationManager.RetrieveAllReservations(); Assert.AreEqual(_reservationManager.RetrieveReservation(_reservations[0].ReservationID).Notes, newNotes); }
/// <summary> /// Author: Matt LaMarche /// Created : 1/31/2019 /// The function which runs when Save is clicked /// </summary> private void btnSave_Click(object sender, RoutedEventArgs e) { if (((string)btnSave.Content) == "Submit") { if (!ValidateInput()) { return; } Reservation newReservation = new Reservation { //MemberID = ((Member)txtMembers.SelectedItem).MemberID, // Validated NumberOfGuests = int.Parse(txtNumGuests.Text), // Validated NumberOfPets = int.Parse(txtNumPets.Text), // Validated ArrivalDate = DateTime.Parse(dtpArrivalDate.Text), // Validated DepartureDate = DateTime.Parse(dtpDepartureDate.Text), // Validated Notes = txtNotes.Text // Optional }; try { if (_existingReservation == null) { _reservationManager.AddReservation(newReservation); SetError(""); MessageBox.Show("Reservation Created Successfully: " + "\nMemberID: " + newReservation.MemberID + "\nNumberOfGuests: " + newReservation.NumberOfGuests + "\nNumberOfPets: " + newReservation.NumberOfPets + "\nArrivalDate: " + newReservation.ArrivalDate.ToString("MM/dd/yyyy") + "\nDepartureDate: " + newReservation.DepartureDate.ToString("MM/dd/yyyy") + "\nNotes: " + newReservation.Notes); } else { newReservation.Active = (bool)chkActive.IsChecked; _reservationManager.EditReservation(_existingReservation, newReservation); SetError(""); MessageBox.Show("Reservation Updated Successfully: " + "\nOld MemberID: " + _existingReservation.MemberID + "\nOld NumberOfGuests: " + _existingReservation.NumberOfGuests + "\nOld NumberOfPets: " + _existingReservation.NumberOfPets + "\nOld ArrivalDate: " + _existingReservation.ArrivalDate.ToString("MM/dd/yyyy") + "\nOld DepartureDate: " + _existingReservation.DepartureDate.ToString("MM/dd/yyyy") + "\nOld Notes: " + _existingReservation.Notes + "\nNew MemberID: " + newReservation.MemberID + "\nNew NumberOfGuests: " + newReservation.NumberOfGuests + "\nNew NumberOfPets: " + newReservation.NumberOfPets + "\nNew ArrivalDate: " + newReservation.ArrivalDate.ToString("MM/dd/yyyy") + "\nNew DepartureDate: " + newReservation.DepartureDate.ToString("MM/dd/yyyy") + "\nNew Notes: " + newReservation.Notes); } } catch (Exception ex) { SetError(ex.Message); } Close(); } else if (((string)btnSave.Content) == "Update") { setEditable(); } else { MessageBox.Show(btnSave.Content.GetType() + " " + btnSave.Content); } }