public void Update_IdDoesNotMatchItemId_ReturnBadRequest() { var poi = CityPoiItemBuilder.GeneratePointOfInterest(); var poiDto = DtoMapper.PoiToPoiDto(poi); var result = PoiController.UpdatePointOfInterest(NotMatchingId, poiDto); result.Should().BeOfType <BadRequestResult>(); }
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>(); }
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>(); }
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))); }