コード例 #1
0
        public List<AdventureLocation> GetNearByAdventureLocations(GeoPoint point, GeoRange range)
        {
            var locations = new List<AdventureLocation>
                                {
                                    new AdventureLocation(point, "test00"),
                                    new AdventureLocation(point, "test01"),
                                    new AdventureLocation(point, "test02"),
                                    new AdventureLocation(point, "test03"),
                                    new AdventureLocation(point, "test04"),
                                    new AdventureLocation(point, "test05"),
                                    new AdventureLocation(point, "test06"),
                                    new AdventureLocation(point, "test07"),
                                    new AdventureLocation(point, "test08")
                                };

            return locations;

            /*
            var setting = new ConnectionSettings(ElasticServer, 9200);
            setting.SetDefaultIndex("pins");

            //request.ValidateRange(_defaultRangeSetting);

            var client = new ElasticClient(setting);

            var results = client.Search<Spot>(s => s
                .From(0) // skip
                .Size(10) // limit
                .Filter(f => f
                        .GeoDistance("geo.location", filter =>
                            filter
                            .Location(point.Lat, point.Lon)
                            .Distance(range.ToString())))
                .Index("pins") // which index
                .Type("location") // what type in the index
                );

            return results.Documents.ToList();
            */
        }
コード例 #2
0
        public void OnPostNewTest()
        {
            var geoPoint = new GeoPoint { Lat = 0, Lon = 0 };
            const string name = "Name";
            var newLocationRequest = new AdventureLocation(geoPoint, name);
            var newLocationResponse = new AdventureLocation(geoPoint, name) { Id = "newId" };
            var expectedNewResponse = new AdventureLocationSaveResponse(newLocationRequest) { AdventureLocation = newLocationResponse };

            var mock = new Mock<IAdventureLocationRepository>();
            mock.Setup(a => a.SaveAdventureLocation(newLocationRequest)).Returns(newLocationResponse);

            var target = new AdventureLocationService { AdventureLocationRepository = mock.Object };

            var actual = target.OnPost(newLocationRequest) as AdventureLocationSaveResponse;
            Assert.AreEqual(expectedNewResponse, actual);
        }
コード例 #3
0
ファイル: Region.cs プロジェクト: JoeHosman/HTA
 public Region(GeoPoint geoPoint, string name)
     : base(geoPoint, name)
 {
 }
コード例 #4
0
        public void OnPostNewTest()
        {
            const string regionname = "regionName";
            var geoPoint = new GeoPoint { Lat = 0, Lon = 0 };

            var newRegionRequest = new Region
                                       {
                                           Name = regionname,
                                           Point = geoPoint
                                       };
            var newRegion = new Region
            {
                Id = "newId",
                Name = regionname,
                Point = geoPoint
            };

            var expectedNewRegionResponse = new AdventureRegionSaveResponse(newRegionRequest)
                                                {
                                                    AdventureRegion = newRegion
                                                };

            var mock = new Mock<IAdventureRegionRepository>();
            mock.Setup(a => a.SaveAdventureRegion(newRegionRequest)).Returns(newRegion);

            var target = new AdventureRegionService {AdventureRegionRepository = mock.Object};

            var actual = target.OnPost(newRegionRequest) as AdventureRegionSaveResponse;
            Assert.IsNotNull(actual);
            Assert.AreEqual(expectedNewRegionResponse, actual);
        }
コード例 #5
0
ファイル: AdventureLocation.cs プロジェクト: JoeHosman/HTA
 public AdventureLocation(GeoPoint geoPoint, string name)
     : base(geoPoint, name)
 {
     Region = new Region(geoPoint, name);
 }