public IActionResult GetPlaces([FromBody] PlacesPostModel placesPostModel)
        {
            //Check if place names was sent from the client
            if (placesPostModel == null || placesPostModel.PlaceNames == null || placesPostModel.PlaceNames.Count() < 1)
            {
                return(new BadRequestObjectResult(ModelState));
            }

            //Get the places information
            var places = IPlaceService.GetPlaces(placesPostModel.PlaceNames.ToList(), 5, OrderByQuery.Cheapest);

            if (places == null || places.Count < 1)
            {
                return(new NoContentResult());
            }

            //Convert Place models to view models
            var placeViewModels = IModelTransformer.PlacesToViewModels(places);

            //Check if converstion returned a view model
            if (placeViewModels == null)
            {
                return(new NoContentResult());
            }

            //Return list of place view models to client
            return(new OkObjectResult(placeViewModels));
        }
            public void Send_No_Valid_PlaceName_Should_Return_NoContentResult()
            {
                // Given
                var placesList = new PlacesPostModel {
                    PlaceNames = new List <string>()
                    {
                        "KiwiLand", "AussieLand"
                    }
                };

                // When
                var result = PlaceController.GetPlaces(placesList);

                // Then
                Assert.IsType <NoContentResult>(result);
            }
            public void Send_Valid_PlaceName_Should_Return_OkObjectResult_With_A_List_Of_PlaceViewModels()
            {
                // Given
                var placesList = new PlacesPostModel {
                    PlaceNames = new List <string>()
                    {
                        "New_York_City", "Tokyo"
                    }
                };

                // When
                var result = PlaceController.GetPlaces(placesList);

                // Then
                var okResult = Assert.IsType <OkObjectResult>(result);

                Assert.IsType <List <PlaceViewModel> >(okResult.Value);
            }
            public void Send_Only_1_PlaceName_Should_Return_OkObjectResult_With_A_List_Of_Only_1_PlaceViewModel()
            {
                // Given
                var placesList = new PlacesPostModel {
                    PlaceNames = new List <string>()
                    {
                        "New_York_City", "AussieLand"
                    }
                };

                // When
                var result = PlaceController.GetPlaces(placesList);

                // Then
                var okResult = Assert.IsType <OkObjectResult>(result);

                Assert.IsType <List <PlaceViewModel> >(okResult.Value);
                var placeViewModels = (List <PlaceViewModel>)okResult.Value;

                Assert.True(placeViewModels.Count == 1);
            }