public async void TestControllerDelete() { var resultPass = await _controller.Delete(-1); var resultFail = await _controller.Delete(2); Assert.NotNull(resultFail); Assert.NotNull(resultPass); }
public void DeleteLodgingDeletesLodgingWithProvidedId() { var lodging = LodgingModel.ToEntity(); LodgingLogicMock.Setup(m => m.Delete(lodging.Id)); var result = LodgingController.Delete(lodging.Id) as NoContentResult; LodgingLogicMock.VerifyAll(); Assert.AreEqual(result.StatusCode, 204); }
public void DeleteLodgingNotFountTest() { var lodgingManagementMock = new Mock <ILodgingManagement>(MockBehavior.Strict); lodgingManagementMock.Setup(m => m.RemoveLodging(It.IsAny <Guid>())).Throws(new ClientBusinessLogicException("El hospedaje a eliminar no ha sido encontrado.")); LodgingController lodgingController = new LodgingController(lodgingManagementMock.Object); var result = lodgingController.Delete(lodgingModelForRequest.Id); var createdResult = result as NotFoundObjectResult; lodgingManagementMock.VerifyAll(); Assert.AreEqual(404, createdResult.StatusCode); }
public void DeleteLodgingTestWithInternalError() { var lodgingManagementMock = new Mock <ILodgingManagement>(MockBehavior.Strict); lodgingManagementMock.Setup(m => m.RemoveLodging(It.IsAny <Guid>())).Throws(new ServerBusinessLogicException("No se puede eliminar el hospedaje.")); LodgingController lodgingController = new LodgingController(lodgingManagementMock.Object); var result = lodgingController.Delete(lodgingModelForRequest.Id); var createdResult = result as ObjectResult; lodgingManagementMock.VerifyAll(); Assert.AreEqual(500, createdResult.StatusCode); }
public void DeleteValidLodgingTest() { var lodgingManagementMock = new Mock <ILodgingManagement>(MockBehavior.Strict); lodgingManagementMock.Setup(m => m.RemoveLodging(It.IsAny <Guid>())); LodgingController lodgingController = new LodgingController(lodgingManagementMock.Object); var result = lodgingController.Delete(lodgingModelForRequest.Id); var createdResult = result as NoContentResult; lodgingManagementMock.VerifyAll(); Assert.AreEqual(204, createdResult.StatusCode); }