本文整理汇总了C#中Keen.Core.KeenClient.SendCachedEventsAsync方法的典型用法代码示例。如果您正苦于以下问题:C# KeenClient.SendCachedEventsAsync方法的具体用法?C# KeenClient.SendCachedEventsAsync怎么用?C# KeenClient.SendCachedEventsAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Keen.Core.KeenClient
的用法示例。
在下文中一共展示了KeenClient.SendCachedEventsAsync方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Async_Caching_SendInvalidEvents_Throws
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();
}
示例2: CachingPCL_SendEventsParallel_Success
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");
}
示例3: Async_Caching_SendEvents_Success
public async Task Async_Caching_SendEvents_Success()
{
var client = new KeenClient(settingsEnv, new EventCacheMemory());
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("CachedEventTest").Value.AsEnumerable().Count(), 3, "Expected exactly 3 collection members");
return new List<CachedEvent>();
}));
client.AddEvent("CachedEventTest", new { AProperty = "AValue" });
client.AddEvent("CachedEventTest", new { AProperty = "AValue" });
client.AddEvent("CachedEventTest", new { AProperty = "AValue" });
await client.SendCachedEventsAsync();
Assert.Null(await client.EventCache.TryTake(), "Cache should be empty");
}
示例4: CachingPCL_SendEventsParallel_Success
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");
}