public void ListEventsTest() { EventDataCollection expectedEventDataCollection = GetEventDataCollection(); var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(expectedEventDataCollection.ToJson()) }; var handler = new RecordedDelegatingHandler(response) { StatusCodeToReturn = HttpStatusCode.OK }; var startTime = DateTimeOffset.Parse("2014-03-11T01:00:00.00Z"); var endTime = DateTimeOffset.Parse("2014-03-11T02:00:00.00Z"); var insightsClient = GetInsightsClient(handler); var filterString = FilterString.Generate <ListEventsParameters>( p => (p.EventTimestamp >= startTime) && (p.EventTimestamp < endTime)); var actualEventDataCollection = insightsClient.EventOperations.ListEvents(filterString, selectedProperties: string.Empty); AreEqual(expectedEventDataCollection, actualEventDataCollection.EventDataCollection); }
private static void AreEqual(EventDataCollection exp, EventDataCollection act) { if (exp != null) { for (int i = 0; i < exp.Value.Count; i++) { AreEqual(exp.Value[i], act.Value[i]); } } }
public async Task <Response <EventDataCollection> > ListAsync(string filter = null, string select = null, CancellationToken cancellationToken = default) { using var message = CreateListRequest(filter, select); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { EventDataCollection value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = EventDataCollection.DeserializeEventDataCollection(document.RootElement); return(Response.FromValue(value, message.Response)); }
public void ListEventsNextTest() { EventDataCollection expectedEventDataCollection = GetEventDataCollection(); var response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(expectedEventDataCollection.ToJson()) }; var handler = new RecordedDelegatingHandler(response) { StatusCodeToReturn = HttpStatusCode.OK }; var insightsClient = GetInsightsClient(handler); var actualEventDataCollection = insightsClient.EventOperations.ListEventsNext("http://www.microsoft.com"); AreEqual(expectedEventDataCollection, actualEventDataCollection.EventDataCollection); }
/// <summary> /// Save cache Track events. /// </summary> /// <returns></returns> public async Task <bool> SaveMixpanelTempData() { EventDataCollection collectionItem = null; var tempJson = await ReadFile(); if (!string.IsNullOrEmpty(tempJson)) { collectionItem = JsonConvert.DeserializeObject <EventDataCollection>(tempJson); } if (collectionItem == null) { collectionItem = new EventDataCollection(); } collectionItem.Collection.AddRange(TempEventCollection); TempEventCollection.Clear(); string newJson = JsonConvert.SerializeObject(collectionItem); await WriteFile(newJson); return(true); }