Exemplo n.º 1
0
        public async Task AddEvent_AddClearEmpty_Success(IEventCache cache)
        {
            await cache.AddAsync(new CachedEvent("url", JObject.FromObject(new { Property = "Value" })));

            await cache.ClearAsync();

            Assert.Null(await cache.TryTakeAsync());
        }
Exemplo n.º 2
0
        public async Task CachingPCL_SendEventsParallel_Success(IEventCache cache)
        {
            await cache.ClearAsync();

            var client = new KeenClient(SettingsEnv, cache);

            if (UseMocks)
            {
                client.Event = new EventMock(SettingsEnv,
                                             addEvents: (e, p) => new List <CachedEvent>());
            }

            (from i in Enumerable.Range(1, 100)
             select new { Property = "Value" })
            .AsParallel()
            .ForAll(e => client.AddEvent("CachedEventTest", e));

            await client.SendCachedEventsAsync();

            Assert.Null(await client.EventCache.TryTakeAsync(), "Cache is empty");
        }