public async void Test_Controller_Put() { LodgingModel lodgingmodel = await _unitOfWork.Lodging.SelectAsync(2); var resultPass = await _controller.Put(lodgingmodel); var resultFail = await _controller.Put(null); Assert.NotNull(resultPass); Assert.NotNull(resultFail); }
public void ModifyLodgingCapacityReturnsValidModelWithCapacityModified() { var lodging = LodgingModel.ToEntity(); var lodgingToReturn = LodgingModel.ToEntity(); lodgingToReturn.IsFull = !lodging.IsFull; LodgingLogicMock.Setup(m => m.Update(lodging.Id)).Returns(lodgingToReturn); var result = LodgingController.Put(lodging.Id) as OkObjectResult; var content = result.Value as LodgingModifiedModel; LodgingLogicMock.VerifyAll(); Assert.IsTrue(content.Equals(new LodgingModifiedModel(lodgingToReturn))); }
public async void TestControllerPut() { LodgingModel lodgingmodel = (await _unitOfWork.Lodging.SelectAsync(e => e.EntityId == 2)).FirstOrDefault(); var resultPass = await _controller.Put(lodgingmodel); var resultFail = await _controller.Put(null); Assert.NotNull(resultPass); Assert.NotNull(resultFail); LodgingModel lodgingModelBadId = (await _unitOfWork.Lodging.SelectAsync(e => e.EntityId == 2)).FirstOrDefault(); lodgingModelBadId.EntityId = -1; var resultFail2 = await _controller.Put(lodgingModelBadId); Assert.NotNull(resultFail2); }
public void UpdateLodgingTestOk() { Lodging lodgingUpdated = new Lodging() { Id = lodgingModelForRequest.Id, Name = "Hotel Enjoy Conrad", Images = new List <LodgingPicture> { lodgingPicture }, Address = "En la punta de punta del este", QuantityOfStars = 5, PricePerNight = 150, TouristSpot = touristSpotAdded }; LodgingModelForRequest lodgingModelForRequestToUpdate = new LodgingModelForRequest() { Id = lodgingModelForRequest.Id, Name = "Hotel Enjoy Conrad", Images = new List <string> { image.Path }, }; var lodgingManagementMock = new Mock <ILodgingManagement>(MockBehavior.Strict); lodgingManagementMock.Setup(m => m.UpdateLodging(It.IsAny <Guid>(), It.IsAny <Lodging>())).Returns(lodgingUpdated); LodgingController lodgingController = new LodgingController(lodgingManagementMock.Object); var result = lodgingController.Put(lodgingModelForRequestToUpdate.Id, lodgingModelForRequestToUpdate); var createdResult = result as CreatedAtRouteResult; var model = createdResult.Value as LodgingModelForResponse; lodgingManagementMock.VerifyAll(); LodgingModelForResponse lodgingModelForResponse = new LodgingModelForResponse() { Id = lodgingModelForRequest.Id, Name = "Hotel Enjoy Conrad", ImagesPath = new List <string> { image.Path }, Address = "En la punta de punta del este", QuantityOfStars = 5, PricePerNight = 150, LodgingTouristSpotModel = TouristSpotModelForLodgingResponseModel.ToModel(touristSpotAdded), }; Assert.AreEqual(lodgingModelForResponse, model); }
public void UpdateInvalidLodgingWithAnyErrorFieldTest() { Lodging lodgingUpdated = new Lodging() { Id = lodgingModelForRequest.Id, Name = "", Images = new List <LodgingPicture>() { lodgingPicture }, Address = "En la punta de punta del este", QuantityOfStars = 5, PricePerNight = 150, TouristSpot = touristSpotAdded }; LodgingModelForRequest lodgingModelForRequestToUpdate = new LodgingModelForRequest() { Id = lodgingModelForRequest.Id, Name = "", Images = new List <string> { image.Path }, }; var lodgingManagementMock = new Mock <ILodgingManagement>(MockBehavior.Strict); lodgingManagementMock.Setup(m => m.UpdateLodging(It.IsAny <Guid>(), It.IsAny <Lodging>())). Throws(new DomainBusinessLogicException("No se puede actualizar el hospedaje deseado.")); LodgingController lodgingController = new LodgingController(lodgingManagementMock.Object); var result = lodgingController.Put(lodgingModelForRequestToUpdate.Id, lodgingModelForRequestToUpdate); var createdResult = result as BadRequestObjectResult; lodgingManagementMock.VerifyAll(); Assert.AreEqual(400, createdResult.StatusCode); }
public async void Test_Controller_Put() { var resultPass = await _controller.Put(new LodgingModel()); Assert.NotNull(resultPass); }