示例#1
0
 public EventListResult(JEventListResult jResult) : base(jResult)
 {
     if (jResult == null)
     {
         Images       = new List <ImageImpl>();
         Dates        = new DateImpl[0];
         Place        = new Place(new JPlace());
         Location     = new LocationImpl(new JLocation());
         Participants = new List <Participant>();
         Categories   = new string[0];
         return;
     }
     Id = jResult.Id;
     PublicationDate = DateTimeHelper.GetDateTimeFromUnixTime(jResult.Publication_Date);
     Dates           = jResult.Dates.Select(d => new DateImpl(d));
     Title           = jResult.Title;
     ShortTitle      = jResult.Short_Title;
     Slug            = jResult.Slug;
     Place           = new Place(jResult.Place);
     Description     = jResult.Description;
     BodyText        = jResult.Body_Text;
     Location        = new LocationImpl(jResult.Location);
     Categories      = jResult.Categories;
     Tagline         = jResult.Tagline;
     AgeRestriction  = jResult.Age_Restriction == "0" ? "0+" : jResult.Age_Restriction;
     Price           = jResult.Price;
     IsFree          = jResult.Is_Free;
     Images          = jResult.Images.Select(i => new ImageImpl(i));
     SiteUrl         = jResult.Site_Url;
     Tags            = jResult.Tags;
     Participants    = jResult.Participants.Select(p => new Participant(p));
 }
示例#2
0
        public void CanConvert_checkForType_expectTrue()
        {
            LocationConverter <LocationImpl> locationConverter = new LocationConverter <LocationImpl>((x) => new LocationImpl(x));
            LocationImpl location = new LocationImpl(new Coordinate(1.2, 2.4));

            Assert.True(locationConverter.CanConvert(location.GetType()));
        }
示例#3
0
        public void NearestLocation_LocationWithNearbyLocationWithoutExclusion_ExpectNearestLocation()
        {
            ConcurrentBag <LocationImpl> locations = new ConcurrentBag <LocationImpl>()
            {
                location1, location2, location3, location4
            };

            locationService.CalculateLocationDistances(locations);

            LocationImpl result = locationService.NearestLocation(location1, locations, new List <Guid>());

            Assert.Equal(location3, result);
        }
示例#4
0
        public void CalculateLocationDistances_GivenLocations_ExpectDistancesAdded()
        {
            ConcurrentBag <LocationImpl> locations = new ConcurrentBag <LocationImpl>()
            {
                location1, location2, location3, location4
            };

            locationService.CalculateLocationDistances(locations);

            LocationImpl result = locations.First(loc => loc.Coordinates.Latitude.Equals(5.0));

            Assert.Equal(location3.Guid, result.DistanceToOthers.ElementAt(0).Value);
            Assert.Equal(location4.Guid, result.DistanceToOthers.ElementAt(1).Value);
            Assert.Equal(location2.Guid, result.DistanceToOthers.ElementAt(2).Value);
        }
示例#5
0
        public void NextLocation_NoNearbyLocation_ExpectNull()
        {
            ConcurrentBag <LocationImpl> locations = new ConcurrentBag <LocationImpl>()
            {
                location1, location2, location3, location4, location5
            };

            locationService.CalculateLocationDistances(locations);

            LocationImpl result = locationService.NextLocation(location1, locations,
                                                               new List <Guid>()
            {
                location2.Guid, location3.Guid, location4.Guid, location5.Guid
            });

            Assert.Null(result);
        }
示例#6
0
        public void NextLocation_LocationWithNearbyLocationWithExclusion_ExpectNearestLocation()
        {
            ConcurrentBag <LocationImpl> locations = new ConcurrentBag <LocationImpl>()
            {
                location1, location2, location3, location4, location5
            };

            locationService.CalculateLocationDistances(locations);

            LocationImpl result = locationService.NextLocation(location1, locations,
                                                               new List <Guid>()
            {
                location3.Guid
            });

            Assert.Contains(result, new List <LocationImpl>()
            {
                location2, location5, location4
            });
        }