public void DeleteVideoIdNegative() { var mockVideo = new Mock <IVideoLogic>(MockBehavior.Strict); var controller = new VideoController(mockVideo.Object); controller.Add(videoList[0]); var result = controller.Delete(-2); Assert.AreEqual(new NotFoundObjectResult("").ToString(), result.ToString()); }
public void DeleteVideoNotExists() { var mockVideo = new Mock <IVideoLogic>(MockBehavior.Strict); mockVideo.Setup(l => l.Get(1)).Returns(videoList[0]); var controller = new VideoController(mockVideo.Object); var result = controller.Delete(3); Assert.AreEqual(new ObjectResult("").ToString(), result.ToString()); }
protected void btnDelete_Click1(object sender, EventArgs e) { try { string del_list = hdfCheck.Value; string[] sp_list = del_list.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < sp_list.Length; i++) { objVideo.Delete(int.Parse(sp_list[i])); } loadData(); } catch (Exception ex) { divMessage.InnerHtml = LibraryO2S.O2S_Message.Error("Cảnh Báo", "Phát hiện lỗi! " + ex.Message); } }
public async void Delete_Errors() { VideoControllerMockFacade mock = new VideoControllerMockFacade(); var mockResult = new Mock <ActionResponse>(); mockResult.SetupGet(x => x.Success).Returns(false); mock.ServiceMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.FromResult <ActionResponse>(mockResult.Object)); VideoController controller = new VideoController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object); controller.ControllerContext = new ControllerContext(); controller.ControllerContext.HttpContext = new DefaultHttpContext(); IActionResult response = await controller.Delete(default(int)); response.Should().BeOfType <ObjectResult>(); (response as ObjectResult).StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); mock.ServiceMock.Verify(x => x.Delete(It.IsAny <int>())); }
public async Task DeleteTest() { var actual = await controller.Create(new Video() { Name = "DeleteVideo", UserId = "1" }); Assert.IsType <CreatedResult>(actual); CreatedResult result = actual as CreatedResult; var item = result.Value as Video; var actual2 = await controller.Delete(Guid.Parse(item.Id)); Assert.IsType <OkObjectResult>(actual2); var actual3 = await controller.GetById(Guid.Parse(item.Id)); Assert.IsType <OkObjectResult>(actual3); OkObjectResult result3 = actual3 as OkObjectResult; var item3 = result3.Value as Video; Assert.Null(item3); }