public async Task TestDeleteSuccessfully() { //Arrange var listToDelete = new List <AttendanceReports>(); AttendanceReports attendance = new AttendanceReports() { AttendanceId = 1, Status = "future", TimeTableId = 1, UserId = "1" }; AttendanceReports attendance1 = new AttendanceReports() { AttendanceId = 2, Status = "future", TimeTableId = 1, UserId = "2" }; listToDelete.Add(attendance); listToDelete.Add(attendance1); await context.AttendanceReports.AddRangeAsync(listToDelete); await context.SaveChangesAsync(); //Act var result = await attendanceDAO.DeleteAttendance(listToDelete); var listAfterDelete = await context.AttendanceReports.ToListAsync(); //Assert Assert.Equal((int)HttpStatusCode.OK, ((ObjectResult)result).StatusCode); Assert.Empty(listAfterDelete); }
/// <summary> /// 선택된 행 삭제 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelete_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("일련번호 " + dataGridView1.SelectedCells[0].Value + "번 기록을 정말로 삭제하시겠습니까?", "", MessageBoxButtons.YesNo, MessageBoxIcon.None, MessageBoxDefaultButton.Button2); if (result == DialogResult.Yes) { try { ad.DeleteAttendance(Int32.Parse(dataGridView1.SelectedCells[0].Value.ToString())); MessageBox.Show("삭제 성공"); } catch (Exception) { MessageBox.Show("삭제 실패"); } } else { MessageBox.Show("취소되었습니다"); } Attendance_Load(null, null); }