public async Task DeleteTest_ReturnsNotFound_WhenIdIsNullOrEmpty() { // Arrange string Id = ""; // Act var result = await controller.Delete(Id); // Assert var viewResult = Assert.IsType <NotFoundResult>(result); }
public void ShouldReturnBadRequestWhenDeletionFailed() { int idToDelete = 1; serviceMock.Setup(x => x.Delete(idToDelete)).Returns(false); var result = controller.Delete(idToDelete); serviceMock.Verify(x => x.Delete(idToDelete), Times.Once()); Assert.IsInstanceOf <BadRequestResult>(result); }
public ActionResult Delete(FormCollection _form) { ScheduleController sc = new ScheduleController(Server); return((ActionResult)sc.Delete(Request)["view"]); //return null; }
public void DeleteSchedule_WhereScheduleExists_ReturnsOkResponse([Values(1, 2, 3)] int idOfScheduleToBeDeleted) { //arrange Mock.Arrange(() => _mockScheduleService.Delete(idOfScheduleToBeDeleted)).OccursOnce(); var scheduleController = new ScheduleController(_mockScheduleService); //act var actual = scheduleController.Delete(idOfScheduleToBeDeleted) as OkResult; //assert Mock.Assert(_mockScheduleService); Assert.That(actual, Is.TypeOf <OkResult>()); }
public async void ScheduleController_Delete_Should_Return200_WhenServiceDoesNotThrowNotFound() { _scheduleService.Setup(service => service.DeleteSchedule(It.IsAny <int>(), It.IsAny <int>())); var controller = new ScheduleController(_scheduleService.Object); controller.ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { User = _mockUser } }; var result = await controller.Delete(1); result.Should().BeOfType <NoContentResult>(); }