public void Delete_PoiIsNotInRepository_ReturnsNotFound() { const int badId = 0; //Arrange var city = CityPoiItemBuilder.GenerateCity(); FakeCityRepository.CityExists(city.Id).Returns(true); FakeCityRepository.GetCity(city.Id, true).Returns(city); //Action var result = PoiController.DeletePointOfIntetest(city.Id, badId); // Assert result.Should().BeOfType <NotFoundResult>(); }
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 void Delete_ItemIsInRepository_ReturnNoContentResult() { //Arrange var city = CityPoiItemBuilder.GenerateCity(); var poi = city.PointsOfInterest.First(); FakeCityRepository.CityExists(city.Id).Returns(true); FakeCityRepository.GetPointOfInterestForCity(city.Id, poi.Id).Returns(poi); FakeCityRepository.GetCity(city.Id, true).Returns(city); //Action var result = PoiController.DeletePointOfIntetest(city.Id, city.PointsOfInterest.First().Id); // Assert result.Should().BeOfType <NoContentResult>(); }
public void Delete_CityAndPoiIsInRepository_CallDeletePoiInRepository() { //Arrange var city = CityPoiItemBuilder.GenerateCity(); var poi = city.PointsOfInterest.First(); FakeCityRepository.GetCity(city.Id, true).Returns(city); FakeCityRepository.GetPointOfInterestForCity(city.Id, poi.Id).Returns(poi); FakeCityRepository.CityExists(city.Id).Returns(true); //Action PoiController.DeletePointOfIntetest(city.Id, poi.Id); // Assert FakeCityRepository.Received().DeletePointOfInterest(city.PointsOfInterest.First()); }
public void GetCity_ItemExistAndPOIisNotRequested_ReturnCityWithNoPOIDTO() { var city = CityPoiItemBuilder.GenerateCity(); var cityDto = new CityWithNoPoidto { CityId = city.Id, Name = city.Name, Country = city.Country, Population = city.Population }; FakeCityRepository.GetCity(city.Id, false).Returns(city); var result = CityPoiController.GetCity(city.Id, false); result.Should().BeOfType <ObjectResult>().Which.Value.ShouldBeEquivalentTo(cityDto); }