AddEventAsync() public method

Add a single event to the specified collection.
public AddEventAsync ( string collection, object eventInfo, IEnumerable addOns = null ) : System.Threading.Tasks.Task
collection string Collection name
eventInfo object The event to add.
addOns IEnumerable Optional collection of Data Enhancement Add-ons
return System.Threading.Tasks.Task
コード例 #1
0
        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
0
 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
0
        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" }));
        }