public async Task AddEvent_AddNotEmpty_Success(IEventCache cache) { await cache.Clear(); Assert.Null(await cache.TryTake()); await cache.Add(new CachedEvent("url", JObject.FromObject( new { AProperty = "AValue" }))); Assert.NotNull(await cache.TryTake()); }
public async Task AddEvent_AddClearEmpty_Success(IEventCache cache) { await cache.Add(new CachedEvent("url", JObject.FromObject(new { AProperty = "AValue" }))); await cache.Clear(); Assert.Null(await cache.TryTake()); }
public async void AddEvent_Iterate_Success(IEventCache cache) { await cache.Clear(); await cache.Add(new CachedEvent("url", JObject.FromObject(new { AProperty = "AValue" }))); await cache.Add(new CachedEvent("url", JObject.FromObject(new { AProperty = "AValue" }))); Assert.NotNull(await cache.TryTake()); Assert.NotNull(await cache.TryTake()); Assert.Null(await cache.TryTake()); }
public async Task CachingPCL_SendEventsParallel_Success(IEventCache cache) { await cache.Clear(); 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 { AProperty = "AValue" }) .AsParallel() .ForAll(e => client.AddEvent("CachedEventTest", e)); await client.SendCachedEventsAsync(); Assert.Null(await client.EventCache.TryTake(), "Cache is empty"); }
public async void CachingPCL_SendEventsParallel_Success(IEventCache cache) { await cache.Clear(); var client = new KeenClient(settingsEnv, cache); if (UseMocks) { client.Event = new EventMock(settingsEnv, AddEvents: new Func <JObject, IProjectSettings, IEnumerable <CachedEvent> >((e, p) => { return(new List <CachedEvent>()); })); } (from i in Enumerable.Range(1, 100) select new { AProperty = "AValue" }) .AsParallel() .ForAll((e) => client.AddEvent("CachedEventTest", e)); await client.SendCachedEventsAsync(); Assert.Null(await client.EventCache.TryTake(), "Cache is empty"); }
public async Task CachingPCL_SendEventsParallel_Success(IEventCache cache) { await cache.Clear(); 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 { AProperty = "AValue" }) .AsParallel() .ForAll(e=>client.AddEvent("CachedEventTest", e)); await client.SendCachedEventsAsync(); Assert.Null(await client.EventCache.TryTake(), "Cache is empty"); }
public async void CachingPCL_SendEventsParallel_Success(IEventCache cache) { await cache.Clear(); var client = new KeenClient(settingsEnv, cache); if (UseMocks) client.Event = new EventMock(settingsEnv, AddEvents: new Func<JObject, IProjectSettings, IEnumerable<CachedEvent>>((e, p) => { return new List<CachedEvent>(); })); (from i in Enumerable.Range(1,100) select new { AProperty = "AValue" }) .AsParallel() .ForAll((e)=>client.AddEvent("CachedEventTest", e)); await client.SendCachedEventsAsync(); Assert.Null(await client.EventCache.TryTake(), "Cache is empty"); }