public AddEventAsync ( string collection, object eventInfo, IEnumerable |
||
collection | string | Collection name |
eventInfo | object | The event to add. |
addOns | IEnumerable |
Optional collection of Data Enhancement Add-ons |
Результат | System.Threading.Tasks.Task |
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" }); }
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" }); }
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" })); }