当前位置: 首页>>代码示例>>C#>>正文


C# KeenClient.AddEvents方法代码示例

本文整理汇总了C#中Keen.Core.KeenClient.AddEvents方法的典型用法代码示例。如果您正苦于以下问题:C# KeenClient.AddEvents方法的具体用法?C# KeenClient.AddEvents怎么用?C# KeenClient.AddEvents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Keen.Core.KeenClient的用法示例。


在下文中一共展示了KeenClient.AddEvents方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddEvents_InvalidProject_Throws

 public void AddEvents_InvalidProject_Throws()
 {
     var settings = new ProjectSettingsProvider(projectId: "X", writeKey: settingsEnv.WriteKey);
     var client = new KeenClient(settings);
     if (UseMocks)
         client.Event = new EventMock(settings,
             AddEvents: new Func<JObject, IProjectSettings, IEnumerable<CachedEvent>>((e, p) =>
             {
                 if ((p == settings)
                     &&(p.ProjectId=="X"))
                     throw new KeenException();
                 else
                     throw new Exception("Unexpected value");
             }));
     Assert.Throws<KeenException>(() => client.AddEvents("AddEventTest", new []{ new {AProperty = "AValue" }}));
 }
开发者ID:kidchenko,项目名称:keen-sdk-net,代码行数:16,代码来源:KeenClientTest.cs

示例2: AddEvents_PartialFailure_Throws

        public void AddEvents_PartialFailure_Throws()
        {
            var client = new KeenClient(settingsEnv);
            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);

            Assert.Throws<KeenBulkException>(() => client.AddEvents("AddEventTest", events));
        }
开发者ID:kidchenko,项目名称:keen-sdk-net,代码行数:23,代码来源:KeenClientTest.cs

示例3: AddEvents_Cache_Success

        public void AddEvents_Cache_Success()
        {
            var client = new KeenClient(settingsEnv, new EventCacheMemory());
            if (UseMocks)
                client.Event = new EventMock(settingsEnv,
                    AddEvents: new Func<JObject, IProjectSettings, IEnumerable<CachedEvent>>((e, p) =>
                    {
                        // Should not be called with caching enabled
                        Assert.Fail();
                        return new List<CachedEvent>();
                    }));

            var events = from i in Enumerable.Range(1, 3)
                         select new { AProperty = "AValue" + i };

            Assert.DoesNotThrow(() => client.AddEvents("AddEventTest", events));

            // reset the AddEvents mock
            if (UseMocks)
                client.Event = new EventMock(settingsEnv,
                    AddEvents: new Func<JObject, IProjectSettings, IEnumerable<CachedEvent>>((e, p) =>
                    {
                        Assert.True(p == settingsEnv, "Incorrect settings");
                        Assert.NotNull(e.Property("AddEventTest"), "Expected collection not found");
                        Assert.AreEqual(e.Property("AddEventTest").Value.AsEnumerable().Count(), 3, "Expected exactly 3 collection members");
                        foreach (dynamic q in ((dynamic)e).AddEventTest)
                            Assert.NotNull(q.keen.timestamp, "keen.timestamp properties should exist");
                        return new List<CachedEvent>();
                    }));
            Assert.DoesNotThrow(() => client.SendCachedEvents());
        }
开发者ID:kidchenko,项目名称:keen-sdk-net,代码行数:31,代码来源:KeenClientTest.cs

示例4: AddEvents_NoCache_Success

        public void AddEvents_NoCache_Success()
        {
            var client = new KeenClient(settingsEnv);
            var done = false;
            if (UseMocks)
                client.Event = new EventMock(settingsEnv,
                    AddEvents: new Func<JObject, IProjectSettings, IEnumerable<CachedEvent>>((e, p) =>
                    {
                        done = true;
                        Assert.True(p == settingsEnv, "Incorrect settings");
                        Assert.NotNull(e.Property("AddEventTest"), "Expected collection not found");
                        Assert.AreEqual(e.Property("AddEventTest").Value.AsEnumerable().Count(), 3, "Expected exactly 3 collection members");
                        foreach (dynamic q in ((dynamic)e).AddEventTest)
                            Assert.NotNull(q.keen.timestamp, "keen.timestamp properties should exist");
                        return new List<CachedEvent>();
                    }));

            var events = from i in Enumerable.Range(1,3)
                         select new { AProperty = "AValue" + i};

            Assert.DoesNotThrow(() => client.AddEvents("AddEventTest", events));
            Assert.True((UseMocks && done) || !UseMocks, "AddEvent mock was not called");
        }
开发者ID:kidchenko,项目名称:keen-sdk-net,代码行数:23,代码来源:KeenClientTest.cs


注:本文中的Keen.Core.KeenClient.AddEvents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。