示例#1
0
        public void UpdatePointOfInterest_PoiIsNull_ReturnBadRequest()
        {
            var result = PoiController.UpdatePointOfInterest(GoodId, null);


            result.Should().BeOfType <BadRequestResult>();
        }
示例#2
0
 public BaseCityControllerTest()
 {
     FakeCityRepository = Substitute.For <ICityRepository>();
     CityPoiController  = new CityPoiController(FakeCityRepository);
     PoiController      = new PoiController(FakeCityRepository);
     CityPoiItemBuilder = new CityPoiItemBuilder();
     DtoMapper          = new DtoMapper();
 }
示例#3
0
        public static void Main()
        {
            CityController cityController = new CityController();
            PoiController  poiController  = new PoiController();

            cityController.CreateCity(new City(2, "Roman", "Unde plm e Roman", 169.0, 169));
            cityController.GetCities();
            poiController.AddPoi(new Poi(1, "What in oblivion is POI?", "Guess i'll die", 1));
            poiController.GetPois();
        }
        public void Init()
        {
            this.uow = new UnitOfWorkMock();

            this.mockIdentity = new Mock <IIdentity>().Object;

            this.controller = new PoiController(this.uow);

            MappingConfig.RegisterMaps();
        }
        public void GetPoiList_CityNotFound_ReturnNotFound()
        {
            //Arrange
            const int badId = -99999999;

            //Action
            var result = PoiController.GetPointsOfInterestForCity(badId);

            // Assert
            result.Should().BeOfType <NotFoundResult>();
        }
        public void Delete_CityIsNotInRepository_ReturnsNotFound()
        {
            //Arrange
            var city = CityPoiItemBuilder.GenerateCity();

            //Action
            var result = PoiController.DeletePointOfIntetest(city.Id, city.PointsOfInterest.First().Id);

            // Assert
            result.Should().BeOfType <NotFoundResult>();
        }
示例#7
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>();
        }
        public void GetPoi_PoiDoesNotExist_ReturnNotFoundResult()
        {
            var city = CityPoiItemBuilder.GenerateCity();

            FakeCityRepository.CityExists(city.Id).Returns(true);


            var result = PoiController.GetPointOfInterest(city.Id, BadId);


            result.Should().BeOfType <NotFoundResult>();
        }
        public void GetPoiList_NoPoiFound_ReturnObjectNotFound()
        {
            //Arrange
            var city = CityPoiItemBuilder.GenerateCity();

            city.PointsOfInterest = null;
            FakeCityRepository.GetPointsOfInterestForCity(city.Id).Returns(city.PointsOfInterest);

            //Action
            var result = PoiController.GetPointsOfInterestForCity(city.Id);

            // Assert
            result.Should().BeOfType <NotFoundResult>();
        }
示例#10
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>();
        }
        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>();
        }
示例#12
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>();
        }
        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 GetPOIList_CityExist_ReturnPOIList()
        {
            //Arrange
            var city = CityPoiItemBuilder.GenerateCity();

            FakeCityRepository.GetPointsOfInterestForCity(city.Id).Returns(city.PointsOfInterest);
            FakeCityRepository.CityExists(city.Id).Returns(true);

            var poiDto = new PointsOfInterestDto
            {
                PoiList = city.PointsOfInterest
            };

            //Action
            var result = PoiController.GetPointsOfInterestForCity(city.Id);


            // Assert
            result.Should().BeOfType <ObjectResult>().Which.Value.ShouldBeEquivalentTo(poiDto);
        }
        public void GetPoi_PoiExist_ReturnPointOfInterestDTO()
        {
            var city   = CityPoiItemBuilder.GenerateCity();
            var poi    = city.PointsOfInterest.First();
            var poiDto = new PointOfInterestDto
            {
                CityId      = poi.CityId,
                Name        = poi.Name,
                Address     = poi.Address,
                Description = poi.Description,
                Id          = poi.Id,
                Latitude    = poi.Latitude,
                Longitude   = poi.Longitude
            };

            FakeCityRepository.GetPointOfInterestForCity(city.Id, poi.Id).Returns(poi);
            FakeCityRepository.CityExists(city.Id).Returns(true);


            var result = PoiController.GetPointOfInterest(city.Id, poi.Id);


            result.Should().BeOfType <ObjectResult>().Which.Value.ShouldBeEquivalentTo(poiDto);
        }