Ejemplo n.º 1
0
        public void Update_IdDoesNotMatchItemId_ReturnBadRequest()
        {
            var poi    = CityPoiItemBuilder.GeneratePointOfInterest();
            var poiDto = DtoMapper.PoiToPoiDto(poi);


            var result = PoiController.UpdatePointOfInterest(NotMatchingId, poiDto);


            result.Should().BeOfType <BadRequestResult>();
        }
Ejemplo n.º 2
0
        public void UpdatePointOfInterest_BadRequest_ReturnBadRequestObjectWithError()
        {
            //Arrange
            var poi    = CityPoiItemBuilder.GeneratePointOfInterest();
            var poiDto = DtoMapper.PoiToPoiDto(poi);

            PoiController.ModelState.AddModelError("Error", "Model state error");

            //Action
            var result = PoiController.UpdatePointOfInterest(poi.Id, poiDto);

            //Assert
            result.Should().BeOfType <BadRequestObjectResult>();
        }
Ejemplo n.º 3
0
        public void UpdatePointOfInterest_PoiFound_CallsUpdateOnRepository()
        {
            var city = CityPoiItemBuilder.GenerateCity();
            var poi  = CityPoiItemBuilder.GeneratePointOfInterest();

            city.PointsOfInterest.Add(poi);
            poi.CityId = city.Id;
            var poiDto = DtoMapper.PoiToPoiDto(poi);

            FakeCityRepository.GetCity(city.Id, IncludePointsOfInterest).Returns(city);

            var result = PoiController.UpdatePointOfInterest(poi.Id, poiDto);

            result.Should().BeOfType <NoContentResult>();
        }
Ejemplo n.º 4
0
        public IActionResult GetPointOfInterest(int cityId, int poiId)
        {
            if (!_repository.CityExists(cityId))
            {
                return(new NotFoundResult());
            }

            var poi = _repository.GetPointOfInterestForCity(cityId, poiId);

            if (poi == null)
            {
                return(new NotFoundResult());
            }

            return(new ObjectResult(_dtoMapper.PoiToPoiDto(poi)));
        }