本文整理汇总了C#中Keen.Core.KeenClient.AddEventAsync方法的典型用法代码示例。如果您正苦于以下问题:C# KeenClient.AddEventAsync方法的具体用法?C# KeenClient.AddEventAsync怎么用?C# KeenClient.AddEventAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Keen.Core.KeenClient
的用法示例。
在下文中一共展示了KeenClient.AddEventAsync方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Async_AddEvent_ValidProjectIdInvalidWriteKey_Throws
public async Task Async_AddEvent_ValidProjectIdInvalidWriteKey_Throws()
{
var settings = new ProjectSettingsProvider(projectId: settingsEnv.ProjectId, writeKey: "X");
var client = new KeenClient(settings);
if (UseMocks)
client.EventCollection = new EventCollectionMock(settings,
AddEvent: new Action<string, JObject, IProjectSettings>((c, e, p) =>
{
if ((p == settings) && (c == "AddEventTest") && (e["AProperty"].Value<string>() == "Value"))
throw new KeenInvalidApiKeyException(c);
}));
await client.AddEventAsync("AddEventTest", new { AProperty = "Value" });
}
示例2: Async_AddEvent_Success
public async Task Async_AddEvent_Success()
{
var client = new KeenClient(settingsEnv);
if (UseMocks)
client.EventCollection = new EventCollectionMock(settingsEnv,
AddEvent: new Action<string, JObject, IProjectSettings>((c, e, p) =>
{
if ((p == settingsEnv) && (c == "AddEventTest") && (e["AProperty"].Value<string>() == "Value"))
throw new KeenResourceNotFoundException(c);
}));
await client.AddEventAsync("AddEventTest", new { AProperty = "AValue" });
}
示例3: Async_AddEvent_InvalidProjectId_Throws
public void Async_AddEvent_InvalidProjectId_Throws()
{
var settings = new ProjectSettingsProvider(projectId: "X", writeKey: SettingsEnv.WriteKey);
var client = new KeenClient(settings);
if (UseMocks)
client.EventCollection = new EventCollectionMock(settings,
addEvent: new Action<string, JObject, IProjectSettings>((c, e, p) =>
{
if ((p == settings) && (c == "AddEventTest") && (e["AProperty"].Value<string>() == "Value"))
throw new KeenResourceNotFoundException(c);
}));
Assert.ThrowsAsync<Keen.Core.KeenResourceNotFoundException>( () => client.AddEventAsync("AddEventTest", new { AProperty = "Value" }));
}