Ejemplo n.º 1
0
        private async Task <List <DealDTO> > CheckConsumerIsInRange()
        {
            List <DealDTO> ConsumerDeals = new List <DealDTO>();

            var consumerBuffer = await GenerateGeoBufferQuery.GenerateBuffer(UserFilters.Range * 1000, UserFilters.Location);



            var queryBody = GeoFenceHelper.CreateRangeCheckJsonBody(consumerBuffer);

            foreach (FilterDeal filterDeal in _filteredDeals)
            {
                var val = GeoFenceHelper.FindRange(queryBody, filterDeal);
                if (val == 0)
                {
                    continue;
                }
                Deal    temp = _deals.First(d => d.Id.Equals(filterDeal.DealId));
                DealDTO deal = new DealDTO
                {
                    DealTitle       = temp.Title,
                    DealDescription = temp.Description,
                    BusinessName    = temp.Business.Name,
                    Latitude        = temp.Business.Location.Latitude,
                    Longitude       = temp.Business.Location.Longitude
                };

                ConsumerDeals.Add(deal);
            }


            return(ConsumerDeals);
        }
        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);
        }