public async Task DeletePilot_WhenCorrectId_ReturnsOkObjectResult() { MockService(); controller = new PilotController(service.Object); var result = await controller.Delete(pilots[0].Id); Assert.IsInstanceOf <OkObjectResult>(result); Assert.IsTrue((result as OkObjectResult).StatusCode == 200); }
public void GoodPilottoDelete() { Pilot pilotInDB = mc.Pilot.First(p => p.Name == "pilotFromTest"); pilotController.Delete(pilotInDB.Id); Pilot search = mc.Pilot.FirstOrDefault(p => p.Name == "pilotFromTest"); Assert.IsNull(search); }
public async Task DeletePilot_WhenNegativeId_ReturnsBadRequestResult() { int pilotId = -1; service = new Mock <IService <PilotDTO> >(); service.Setup(x => x.Remove(It.IsAny <int>())).Throws <ArgumentException>(); controller = new PilotController(service.Object); var result = await controller.Delete(pilotId); Assert.IsInstanceOf <BadRequestResult>(result); Assert.IsTrue((result as BadRequestResult).StatusCode == 400); }
public async Task DeletePilot_WhenWrongId_ReturnsNotFoundResult() { int pilotId = 100; service = new Mock <IService <PilotDTO> >(); service.Setup(x => x.Remove(It.IsAny <int>())).Throws <NotFoundException>(); controller = new PilotController(service.Object); var result = await controller.Delete(pilotId); Assert.IsInstanceOf <NotFoundObjectResult>(result); Assert.IsTrue((result as NotFoundObjectResult).StatusCode == 404); }