示例#1
0
        public static int FindRange(string area, FilterDeal filterDeal)
        {
            string[] result = null;
            PostPointInPolygonRequest req = new PostPointInPolygonRequest
            {
                ApiVersion = "1.0",
                Lon        = filterDeal.LocationDto.Longitude,
                Lat        = filterDeal.LocationDto.Latitude,
            };
            var am = new AzureMapsServices(Constants.AZUREMAPKEY);

            try
            {
                var response = am.PostPointInPolygon(req, area);



                result = response.Result.Result.Result.IntersectingGeometries;
            }
            catch (Exception ex)
            {
                throw new Exception(nameof(FindRange), ex);
            }
            if (result == null || result.Length == 0)
            {
                return(0);
            }

            return(1);
        }
        public void Should_Throw_Exception_When_Bad_Data_Passed()
        {
            //Arrange
            LocationDTO location = new LocationDTO()
            {
                Longitude = 3.33, Latitude = 3.33
            };
            var temp = new FilterDeal()
            {
                DealId = Guid.NewGuid(), LocationDto = location
            };

            //Act
            var result = Record.Exception(() => GeoFenceHelper.FindRange("", temp));

            Assert.IsType <Exception>(result);
        }
        public void Should_Distance_as_a_double()
        {
            //Arrange
            LocationDTO location = new LocationDTO()
            {
                Longitude = 3.33, Latitude = 3.33
            };
            var temp = new FilterDeal()
            {
                DealId = Guid.NewGuid(), LocationDto = location
            };


            //Act
            var result = GeoFenceHelper.FindRange(SetGeoFenceBody(), temp);

            //Assert
            Assert.IsType <int>(result);
            Assert.InRange(result, -1000, 1000);
        }