public async Task should_get_event_details()
        {
            var request = new EventListRequest();

            request.Lang = "ru";

            var fieldBuilder = new FieldsBuilder();

            request.Fields      = fieldBuilder.WithField(EventListRequest.FieldNames.ID).Build();
            request.ActualSince = DateTime.Today;
            request.Location    = Location.Spb;

            //then
            var res = await request.ExecuteAsync();

            var first = res.Results.First();

            var detailsRequest = new EventDetailsRequest();

            detailsRequest.EventId = first.Id;
            var actual = await detailsRequest.ExecuteAsync();

            Assert.IsNotNull(actual);
            Assert.AreEqual(actual.Id, first.Id);
        }
Пример #2
0
        public void ExecuteTranslated()
        {
            // arrange
            var eventId         = new Guid("F479B4CF-2E11-457A-B279-90822511B53B"); // Defeat the Karka Queen threatening the settlements.
            var translatedNames = new Dictionary <LanguageCode, string>()
            {
                { LanguageCode.DE, "Besiegt die Karka-Königin, die die Siedlungen bedroht." },
                { LanguageCode.EN, "Defeat the Karka Queen threatening the settlements." },
                { LanguageCode.ES, "Derrota a la reina karka que amenaza a los asentamientos." },
                { LanguageCode.FR, "Vaincre la reine karka qui menace les colonies." },
            };

            foreach (var pair in translatedNames)
            {
                // act
                var response = new EventDetailsRequest(eventId, pair.Key).Execute();

                // assert
                Assert.AreEqual(1, response.Events.Count);
                Assert.IsTrue(response.Events.ContainsKey(eventId));

                var ev = response.Events[eventId];

                Assert.AreEqual(pair.Value, ev.Name);
            }
        }
        public async Task should_throw_exception()
        {
            var detailsRequest = new EventDetailsRequest();

            detailsRequest.Lang    = "ru";
            detailsRequest.EventId = 10000000000000000;
            var actual = await detailsRequest.ExecuteAsync();
        }
Пример #4
0
        public async Task <IEventDetailsResponse> GetEventDetails(long eventId)
        {
            var request = new EventDetailsRequest();

            request.Lang       = _culture;
            request.EventId    = eventId;
            request.TextFormat = TextFormatEnum.Plain;
            request.Expand     = EventListRequest.ExpandNames.PLACE + "," + EventListRequest.ExpandNames.IMAGES;

            var res = await request.ExecuteAsync();

            return(res);
        }
Пример #5
0
        public void ExecuteSphere()
        {
            // arrange
            var sphereEvent = new Guid("EED8A79F-B374-4AE6-BA6F-B7B98D9D7142"); // Defeat the renegade charr

            // act
            var response = new EventDetailsRequest(sphereEvent).Execute();

            // assert
            Assert.AreEqual(1, response.Events.Count);
            Assert.IsTrue(response.Events.ContainsKey(sphereEvent));

            var ev = response.Events[sphereEvent];

            Assert.AreEqual(LocationType.Sphere, ev.Location.TypeEnum);
            Assert.IsTrue(ev.Location.Radius > 0);
            Assert.IsTrue(ev.Location.Center.Count > 0);
        }
Пример #6
0
        public void ExecutePoly()
        {
            // arrange
            var polyEvent = new Guid("CEA84FBF-2368-467C-92EA-7FA60D527C7B"); // Find a way to open the door and escape the armory

            // act
            var response = new EventDetailsRequest(polyEvent).Execute();

            // assert
            Assert.AreEqual(1, response.Events.Count);
            Assert.IsTrue(response.Events.ContainsKey(polyEvent));

            var ev = response.Events[polyEvent];

            Assert.AreEqual(LocationType.Poly, ev.Location.TypeEnum);
            Assert.IsTrue(ev.Location.Center.Count > 0);
            Assert.IsTrue(ev.Location.ZRange.Count > 0);
            Assert.IsTrue(ev.Location.Points.Count > 0);
        }
Пример #7
0
        public void ExecuteCylinder()
        {
            // arrange
            var cylinderEvent = new Guid("3A2B85C5-DE73-4402-BD84-8F53AA394A52"); // Bonus Event: Cull the Flame Legion

            // act
            var response = new EventDetailsRequest(cylinderEvent).Execute();

            // assert
            Assert.AreEqual(1, response.Events.Count);
            Assert.IsTrue(response.Events.ContainsKey(cylinderEvent));

            var ev = response.Events[cylinderEvent];

            Assert.AreEqual(LocationType.Cylinder, ev.Location.TypeEnum);
            Assert.IsTrue(ev.Location.Radius > 0);
            Assert.IsTrue(ev.Location.Center.Count > 0);
            Assert.IsTrue(ev.Location.Height > 0);
        }
Пример #8
0
        public void Execute()
        {
            //act
            var response = new EventDetailsRequest().Execute();

            // assert
            Assert.IsTrue(response.Events.Count > 1);

            foreach (var ev in response.Events)
            {
                Assert.IsNotNull(ev.Key);
                Assert.IsNotNull(ev.Value.Name);
                Assert.IsNotNull(ev.Value.Location);
                Assert.IsTrue(ev.Value.Level >= 0);
                Assert.IsTrue(ev.Value.MapId > 0);

                Assert.AreNotEqual(EventFlagType.Invalid, ev.Value.FlagsEnum & EventFlagType.Invalid);
                Assert.AreNotEqual(LocationType.Invalid, ev.Value.Location.TypeEnum);
            }
        }
Пример #9
0
        private async Task LoadEventOfTheDay()
        {
            var request = new EventsOfTheDayRequest();

            request.TextFormat = TextFormatEnum.Text;
            request.Location   = Location.Spb;

            var res = await request.ExecuteAsync();

            var eventOfTheDay = res.Results.First().Event;

            var details = new EventDetailsRequest();

            details.EventId = eventOfTheDay.Id;
            var detailsRes = await details.ExecuteAsync();

            //var place = new PlaceRequest();
            //TODO

            EventOfTheDay = new EventViewModel(eventOfTheDay.FirstImage.Thumbnail.Small, eventOfTheDay.Title, null);
            OnPropertyChanged("EventOfTheDay");
        }
Пример #10
0
        public void ExecuteFlags()
        {
            // arrange
            var eventIdMap = new Dictionary <EventFlagType, Guid>()
            {
                { EventFlagType.GroupEvent, new Guid("3A2B85C5-DE73-4402-BD84-8F53AA394A52") }, // Bonus Event: Cull the Flame Legion
                { EventFlagType.MapWide, new Guid("F479B4CF-2E11-457A-B279-90822511B53B") } // Defeat the Karka Queen threatening the settlements.
            };

            foreach (var pair in eventIdMap)
            {
                // act
                var response = new EventDetailsRequest(pair.Value).Execute();

                // assert
                Assert.AreEqual(1, response.Events.Count);
                Assert.IsTrue(response.Events.ContainsKey(pair.Value));

                var ev = response.Events[pair.Value];

                Assert.AreEqual(pair.Key, ev.FlagsEnum & pair.Key);
            }
        }
Пример #11
0
        public EventDetailsResult eventDetails(EventDetailsRequest eventDetailsRequest)
        {
            try
            {
                if (!verifyUser(eventDetailsRequest.connectionId))
                    return new EventDetailsResult();

                EventDetailsResult eventDetailsResult = new EventDetailsResult();
                eventDetailsResult.collaborators = new List<CollaboratorsResult>();
                eventDetailsResult.dateSuggestions = new List<DateSuggResult>();
                eventDetailsResult.notifications = new List<NotificationsResult>();
                eventDetailsResult.timeSuggestions = new List<TimeSuggResult>();
                eventDetailsResult.venueSuggestions = new List<VenueSuggResult>();
                eventDetailsResult.details = new UserEvents();
                var userId = (from u in _entity.connections where u.connection_id == eventDetailsRequest.connectionId select u).FirstOrDefault();

                var timeSugg = (from s in _entity.time_suggestions
                                where s.suggestion.event_id == eventDetailsRequest.eventId
                                select s).ToList();
                foreach (var id1 in timeSugg)
                {
                    eventDetailsResult.timeSuggestions.Add(new TimeSuggResult()
                                                               {
                                                                   suggestionId = id1.suggestion_id,
                                                                   time = id1.time.ToString(),
                                                                   userName = id1.suggestion.user.name,
                                                                   likes = _entity.user_likes.Where(s => s.suggestion_id == id1.suggestion_id && s.type == 1).Count(),
                                                                   dislikes = _entity.user_likes.Where(s => s.suggestion_id == id1.suggestion_id && s.type == 0).Count()
                                                               });
                }

                var dateSugg = (from s in _entity.date_suggestions
                                where s.suggestion.event_id == eventDetailsRequest.eventId
                                select s).ToList();
                foreach (var id1 in dateSugg)
                {
                    eventDetailsResult.dateSuggestions.Add(new DateSuggResult()
                                                                {
                                                                    suggestionId = id1.suggestion_id,
                                                                    date = id1.date,
                                                                    userName = id1.suggestion.user.name,
                                                                    likes = _entity.user_likes.Where(s => s.suggestion_id == id1.suggestion_id && s.type == 1).Count(),
                                                                    dislikes = _entity.user_likes.Where(s => s.suggestion_id == id1.suggestion_id && s.type == 0).Count()
                                                                });
                }

                var venueSugg = (from s in _entity.venue_suggestions
                                 where s.suggestion.event_id == eventDetailsRequest.eventId
                                 select s).ToList();
                foreach (var id1 in venueSugg)
                {
                    eventDetailsResult.venueSuggestions.Add(new VenueSuggResult()
                                                                {
                                                                    suggestionId = id1.suggestion_id,
                                                                    venue = id1.venue,
                                                                    address = id1.address,
                                                                    description = id1.description,
                                                                    coordinates = id1.coordinates,
                                                                    userName = id1.suggestion.user.name,
                                                                    likes = _entity.user_likes.Where(s => s.suggestion_id == id1.suggestion_id && s.type == 1).Count(),
                                                                    dislikes = _entity.user_likes.Where(s => s.suggestion_id == id1.suggestion_id && s.type == 0).Count()
                                                                });
                }

                var notifications =
                    (from n in _entity.notifications where n.event_id == eventDetailsRequest.eventId select n).ToList();
                foreach (var id1 in notifications)
                {
                    eventDetailsResult.notifications.Add(new NotificationsResult()
                                                             {
                                                                 code = id1.code,
                                                                 text = id1.text,
                                                                 userId = id1.user_id
                                                             });
                }

                var coll =
                    (from c in _entity.collaborators where c.event_id == eventDetailsRequest.eventId select c).ToList();
                var onlineUsers = (from u in _entity.connections select u.user_id).ToList();
                foreach (var id1 in coll)
                {
                    eventDetailsResult.collaborators.Add(new CollaboratorsResult()
                                                             {
                                                                 email = id1.user.email,
                                                                 name = id1.user.name,
                                                                 userId = id1.user_id,
                                                                 colorCode = id1.user.color_code,
                                                                 online = onlineUsers.Contains(id1.user_id)
                                                             });
                }

                var ev1 = (from e in _entity.events where e.id == eventDetailsRequest.eventId select e).FirstOrDefault();
                eventDetailsResult.details.code = ev1.code;
                eventDetailsResult.details.name = ev1.name;
                eventDetailsResult.details.date = ev1.date.HasValue ? ev1.date.Value.ToLongDateString() : "";
                eventDetailsResult.details.time = ev1.time;
                eventDetailsResult.details.isOwner = ev1.user_id == userId.user_id ? 1 : 0;
                eventDetailsResult.details.venue = ev1.venue;
                eventDetailsResult.details.eventId = ev1.id;
                eventDetailsResult.details.createdBy = ev1.user.name;

                return eventDetailsResult;
            }
            catch (Exception)
            {
                return new EventDetailsResult();
            }
        }