public ActionResult DeleteLecturer(int lectureid) { JsonResultData <string> resultdata = new JsonResultData <string>(); try { int result = lectureservice.Delete(lectureid); if (result != 2) { resultdata.Code = 0; resultdata.Data = "删除失败"; } else { resultdata.Code = 1; resultdata.Data = "删除成功"; } } catch (Exception ex) { resultdata.Msg = ex.Message; } return(Json(resultdata, JsonRequestBehavior.AllowGet)); }
public async Task DeleteLecture_GivenLectureId_ReturnListWithoutDeletedLecture() { //Arrange var lectures = await lectureService.GetAll(); var lecturesCount = lectures.Count; var lastLecture = lectures[lectures.Count - 1]; //Act await lectureService.Delete(lastLecture.Id); var newLectures = await lectureService.GetAll(); var newLecturesCount = newLectures.Count; //Assert Assert.AreEqual(lecturesCount - 1, newLecturesCount); }