public void GetPointsOfInterestById_RouteWithMultipleAttributes_ShouldReturnIt()
        {
            var poiId   = "poiId";
            var feature = GetValidFeature(poiId, _adapter.Source);

            feature.Attributes.DeleteAttribute(FeatureAttributes.NAME);
            feature.Attributes.Add(FeatureAttributes.IMAGE_URL, FeatureAttributes.IMAGE_URL);
            feature.Attributes.Add(FeatureAttributes.IMAGE_URL + "1", FeatureAttributes.IMAGE_URL + "1");
            feature.Attributes.Add(FeatureAttributes.DESCRIPTION, FeatureAttributes.DESCRIPTION);
            feature.Attributes.Add(FeatureAttributes.WIKIPEDIA + ":en", "page with space");
            _elasticSearchGateway.GetPointOfInterestById(poiId, _adapter.Source).Returns(feature);
            _wikipediaGateway.GetReference("page with space", "en").Returns(new Reference {
                Url = "page_with_space"
            });
            _dataContainerConverterService.ToDataContainer(Arg.Any <byte[]>(), Arg.Any <string>()).Returns(
                new DataContainer
            {
                Routes = new List <RouteData>
                {
                    new RouteData
                    {
                        Segments = new List <RouteSegmentData>
                        {
                            new RouteSegmentData
                            {
                                Latlngs = new List <LatLngTime>
                                {
                                    new LatLngTime(0, 0),
                                    new LatLngTime(0.1, 0.1)
                                }
                            },
                            new RouteSegmentData()
                        }
                    }
                }
            });

            var result = _adapter.GetPointOfInterestById(Sources.OSM, poiId, "en").Result;

            Assert.IsNotNull(result);
            Assert.AreEqual(string.Empty, result.Title);
            Assert.AreEqual(FeatureAttributes.DESCRIPTION, result.Description);
            Assert.AreEqual(2, result.ImagesUrls.Length);
            Assert.AreEqual(FeatureAttributes.IMAGE_URL, result.ImagesUrls.First());
            Assert.IsTrue(result.References.First().Url.Contains("page_with_space"));
            Assert.IsTrue(result.IsRoute);
            Assert.IsTrue(result.LengthInKm > 0);
        }
Exemple #2
0
        public void GetPointsOfInterestById_RouteWithMultipleImagesAndDescriptionOnly_ShouldReturnIt()
        {
            var poiId   = "poiId";
            var feature = GetValidFeature(poiId, _adapter.Source);

            feature.Attributes.DeleteAttribute(FeatureAttributes.NAME);
            feature.Attributes.AddAttribute(FeatureAttributes.IMAGE_URL, FeatureAttributes.IMAGE_URL);
            feature.Attributes.AddAttribute(FeatureAttributes.IMAGE_URL + "1", FeatureAttributes.IMAGE_URL + "1");
            feature.Attributes.AddAttribute(FeatureAttributes.DESCRIPTION, FeatureAttributes.DESCRIPTION);
            feature.Attributes.AddAttribute(FeatureAttributes.POI_TYPE, FeatureAttributes.POI_TYPE);
            _elasticSearchGateway.GetPointOfInterestById(poiId, _adapter.Source, Arg.Any <string>()).Returns(feature);
            _dataContainerConverterService.ToDataContainer(Arg.Any <byte[]>(), Arg.Any <string>()).Returns(
                new DataContainer
            {
                routes = new List <RouteData>
                {
                    new RouteData
                    {
                        segments = new List <RouteSegmentData>
                        {
                            new RouteSegmentData(),
                            new RouteSegmentData()
                        }
                    }
                }
            });

            var result = _adapter.GetPointOfInterestById(poiId, null).Result;

            Assert.IsNotNull(result);
            Assert.AreEqual(string.Empty, result.Title);
            Assert.AreEqual(FeatureAttributes.DESCRIPTION, result.Description);
            Assert.AreEqual(2, result.ImagesUrls.Length);
            Assert.AreEqual(FeatureAttributes.IMAGE_URL, result.ImagesUrls.First());
            Assert.IsTrue(result.IsRoute);
        }