public async void ReturnValidModelForCorrectId(int?id) { var result = await sut.Delete(id); var vr = Assert.IsType <ViewResult>(result); fixture.repositoryWrapper.Verify(y => y.Appointment.GetAppointmentByIdAsync(id), Times.Once); Assert.Equal("Delete", vr.ViewName); Assert.IsAssignableFrom <AppointmentManagementDTO>(vr.Model); }
public void OnDelete() { Appointment appointment = (Appointment)_state[StateKeys.CurrentAppointment]; _controller.Delete(appointment); _navigator.Navigate(NavigationKeys.Home); }
/// <summary> /// Deletes expired records in the database. /// </summary> private void CleanupExpiredRecords() { tasks = taskController.Details(selectedUser.Id); appointments = appointmentController.Details(selectedUser.Id); List <Task> taskQuery = (from task in tasks where task.Date < DateTime.Today select task).ToList(); List <Appointment> appointmentQuery = (from appointment in appointments where appointment.Date < DateTime.Today && appointment.Date != new DateTime(1980, 1, 1) select appointment).ToList(); for (int i = 0; i < taskQuery.Count; i++) { taskController.Delete(taskQuery[i]); } for (int i = 0; i < appointmentQuery.Count; i++) { appointmentController.Delete(appointmentQuery[i]); } }
public void Delete_Test() { // Arrange var mockService = new Mock <IAppointmentService>(); var controller = new AppointmentController(mockService.Object); int id = 10; int userId = 1; // Act IHttpActionResult actionResult = controller.Delete(id, userId); // Assert Assert.IsInstanceOfType(actionResult, typeof(OkResult)); }
public void Appointment_ShouldDeleteAppointment() { // Assemble var mockRepository = new MyMockedRepository(); var appointment = new Appointment { CustomerFullName = "Jane Doe", ServiceProviderFullName = "John Doe", Day = 0, Time = 0 }; mockRepository.AddAppointment(appointment); AppointmentController controller = new AppointmentController(mockRepository); // Act controller.Delete(appointment); // Assert Assert.Empty(mockRepository.Appointments); }
/// <summary> /// Occurs when the value of a cell changes. Adds a new Appointment if there wasn't no value. Edit an existing Appointment if the value changed. Deletes an existing Appointment if the value is empty. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="DataGridViewCellEventArgs"/> instance containing the event data.</param> private void dgvUsers_CellValueChanged(object sender, DataGridViewCellEventArgs e) { dgvUsers.CellValueChanged -= dgvUsers_CellValueChanged; dgvUsers[e.ColumnIndex, e.RowIndex].Value = false; dgvUsers.CellValueChanged += dgvUsers_CellValueChanged; if (e.ColumnIndex == 1) { DialogResult dialogResult = MessageBox.Show("U staat op het punt om deze gebruiker te verwijderen.\nAlle taken, vakken, cijfers en afspraken zullen van deze gebruiker verwijderd worden.", "Gebruiker verwijderen", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { int result = 0; User query = null; uint?id = null; List <DataGridViewRow> rows = (from row in dgvUsers.Rows.Cast <DataGridViewRow>() select row).ToList(); id = (from row in rows where Convert.ToBoolean(row.Cells["verwijderen?"].Value) == true select Convert.ToUInt32(row.Cells[dgvUsers.ColumnCount - 1].Value)).FirstOrDefault(); query = (from user in users where user.Id == id select user).FirstOrDefault(); if (query != null) { tasks = taskController.Details(id); repeatingTasks = repeatingTaskController.Details(id); grades = gradeController.Details(id); subjects = subjectController.Details(id); appointments = appointmentController.Details(id); for (int i = 0; i < tasks.Count; i++) { taskController.Delete(tasks[i]); } for (int i = 0; i < repeatingTasks.Count; i++) { repeatingTaskController.Delete(repeatingTasks[i]); } for (int i = 0; i < grades.Count; i++) { gradeController.Delete(grades[i]); } for (int i = 0; i < subjects.Count; i++) { subjectController.Delete(subjects[i]); } for (int i = 0; i < appointments.Count; i++) { appointmentController.Delete(appointments[i]); } result = userController.Delete(query); if (result == 0) { MessageBox.Show("Kon de gebruiker niet verwijderen."); } else { MessageBox.Show("De gebruiker is succesvol verwijderd."); } } LoadToGrid(); } } }