public void SetUp() { regionForTouristSpot = new Region() { Id = Guid.NewGuid(), Name = Region.RegionName.Región_Centro_Sur }; category = new Category() { Id = Guid.NewGuid(), Name = "Playa" }; touristSpotAdded = new TouristSpot() { Id = Guid.NewGuid(), Name = "Punta del Este", Description = "Un lugar increible", Region = regionForTouristSpot, ListOfCategories = new List <CategoryTouristSpot>() { new CategoryTouristSpot() { Category = category } }, Image = new Picture() { Path = "Desktop/joaco.jpg" } }; touristSpotRequestModel = new TouristSpotForRequestModel() { Id = touristSpotAdded.Id, Name = "Punta del Este", Description = "Un lugar increible", RegionId = regionForTouristSpot.Id, ListOfCategoriesId = new List <Guid>() { category.Id }, ImagePath = "Desktop/joaco.jpg" }; touristSpotResponseModel = new TouristSpotForResponseModel { Id = touristSpotAdded.Id, Name = "Punta del Este", Description = "Un lugar increible", RegionModel = RegionForResponseModel.ToModel(regionForTouristSpot), ListOfCategoriesModel = new List <CategoryModel>() { CategoryModel.ToModel(category) }, ImagePath = "Desktop/joaco.jpg" }; }
public void SetUp() { region = new Region() { Id = Guid.NewGuid(), Name = Region.RegionName.Región_Centro_Sur }; regionModel = new RegionForResponseModel() { Id = region.Id, Name = Region.RegionName.Región_Centro_Sur, DescriptionOfName = "Region Centro Sur" }; }
public IActionResult Get(Guid id) { try { Region region = regionManagement.GetById(id); return(Ok(RegionForResponseModel.ToModel(region))); } catch (ClientBusinessLogicException e) { return(NotFound(e.Message)); } catch (ServerBusinessLogicException e) { return(StatusCode(StatusCodes.Status500InternalServerError, e.Message)); } }
public IActionResult Get() { try { List <Region> allRegions = regionManagement.GetAllRegions(); return(Ok(RegionForResponseModel.ToModel(allRegions))); } catch (ClientBusinessLogicException e) { return(NotFound(e.Message)); } catch (ServerBusinessLogicException e) { return(StatusCode(StatusCodes.Status500InternalServerError, e.Message)); } }
public void CreateTouristSpotNotEqualsIdTest() { TouristSpotForRequestModel touristSpotRequestModel = new TouristSpotForRequestModel() { Id = touristSpotAdded.Id, Name = "Punta del Este", Description = "Un lugar increible", RegionId = regionForTouristSpot.Id, ImagePath = "Desktop/joaco.jpg", ListOfCategoriesId = new List <Guid>() { category.Id } }; var touristSpotMock = new Mock <ITouristSpotManagement>(MockBehavior.Strict); touristSpotMock.Setup(m => m.Create(It.IsAny <TouristSpot>(), It.IsAny <Guid>(), It.IsAny <List <Guid> >())).Returns(touristSpotAdded); TouristSpotController touristSpotController = new TouristSpotController(touristSpotMock.Object); var result = touristSpotController.Post(touristSpotRequestModel); var createdResult = result as CreatedAtRouteResult; var model = createdResult.Value as TouristSpotForResponseModel; touristSpotMock.VerifyAll(); TouristSpotForResponseModel touristSpotResponseModel = new TouristSpotForResponseModel() { Id = Guid.NewGuid(), Name = "Punta del ", Description = "Un lugar increible", RegionModel = RegionForResponseModel.ToModel(regionForTouristSpot), ListOfCategoriesModel = new List <CategoryModel>() { CategoryModel.ToModel(category) } }; Assert.AreNotEqual(touristSpotRequestModel, model); }