AddEventsAsync() public method

Add a collection of events to the specified collection
public AddEventsAsync ( string collection, IEnumerable eventsInfo, IEnumerable addOns = null ) : System.Threading.Tasks.Task
collection string Collection name
eventsInfo IEnumerable Collection of events to add
addOns IEnumerable Optional collection of Data Enhancement Add-ons
return System.Threading.Tasks.Task
Exemplo n.º 1
0
        public async Task Async_Caching_SendInvalidEvents_Throws()
        {
            var client = new KeenClient(settingsEnv, new EventCacheMemory());
            if (UseMocks)
                client.Event = new EventMock(settingsEnv,
                    AddEvents: new Func<JObject, IProjectSettings, IEnumerable<CachedEvent>>((e, p) =>
                    {
                        var err = e.SelectToken("$.AddEventTest[2]") as JObject;
                        if (null == err)
                            throw new Exception("Unexpected error, test data not found");

                        return new List<CachedEvent>() { new CachedEvent("AddEventTest", e) };
                    }));

            object invalidEvent = new ExpandoObject();
            ((IDictionary<string, object>)invalidEvent).Add("$" + new string('.', 260), "AValue");

            var events = (from i in Enumerable.Range(1, 2)
                          select new { AProperty = "AValue" + i }).ToList<object>();
            events.Add(invalidEvent);

            await client.AddEventsAsync("AddEventTest", events);
            await client.SendCachedEventsAsync();
        }
Exemplo n.º 2
0
 public async Task Async_AddEvents_NullCollection_Throws()
 {
     var client = new KeenClient(settingsEnv);
     await client.AddEventsAsync("AddEventTest", null);
 }
Exemplo n.º 3
0
        public async Task Async_AddEvents_Success()
        {
            var client = new KeenClient(settingsEnv);
            if (UseMocks)
                client.Event = new EventMock(settingsEnv,
                    AddEvents: new Func<JObject, IProjectSettings, IEnumerable<CachedEvent>>((e, p) =>
                    {
                        Assert.AreEqual(p, settingsEnv, "Unexpected settings object");
                        Assert.AreEqual(e.Property("AddEventTest").Value.AsEnumerable().Count(), 3, "Expected exactly 3 collection members");
                        return new List<CachedEvent>();
                    }));

            var events = from e in Enumerable.Range(1, 3)
                         select new { AProperty = "Value" + e };

            await client.AddEventsAsync("AddEventTest", events);
        }
Exemplo n.º 4
0
 public void Async_AddEvents_NullCollection_Throws()
 {
     var client = new KeenClient(SettingsEnv);
     Assert.ThrowsAsync<Keen.Core.KeenException>( () => client.AddEventsAsync("AddEventTest", null));
 }