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


C# KeenClient.SendCachedEvents方法代码示例

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


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

示例1: Caching_SendInvalidEvents_Throws

        public void 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) =>
                    {
                        if (p == settingsEnv)
                            throw new KeenBulkException("Mock exception", 
                                new List<CachedEvent>(){new CachedEvent("CachedEventTest", e, new Exception())});
                        else
                            throw new Exception("Unexpected value");
                    }));

            var anEvent = new JObject();
            anEvent.Add("AProperty", "AValue");
            client.AddEvent("CachedEventTest", anEvent);
            
            anEvent.Add("keen", JObject.FromObject(new {invalidPropName = "value"} ));
            client.AddEvent("CachedEventTest", anEvent);
            Assert.DoesNotThrow(() => 
                {
                    try
                    {
                        client.SendCachedEvents();
                    } 
                    catch (KeenBulkException ex)
                    {
                        if (ex.FailedEvents.Count() != 1)
                            throw new Exception("Expected 1 failed event.");
                    }
                });
        }
开发者ID:kidchenko,项目名称:keen-sdk-net,代码行数:33,代码来源:KeenClientTest.cs

示例2: Caching_SendManyEvents_Success

        public async void Caching_SendManyEvents_Success()
        {
            var client = new KeenClient(settingsEnv, new EventCacheMemory());
            var total = 0;
            if (UseMocks)
                client.Event = new EventMock(settingsEnv,
                    AddEvents: new Func<JObject, IProjectSettings, IEnumerable<CachedEvent>>((e, p) =>
                    {
                        if ((p == settingsEnv)
                            && (null != e.Property("CachedEventTest"))
                            && ((e.Property("CachedEventTest").Value.Children().Count() == KeenConstants.BulkBatchSize)))
                        {
                            total += e.Property("CachedEventTest").Value.Children().Count();
                            return new List<CachedEvent>();
                        }
                        else
                            throw new Exception("Unexpected value");
                    }));

            for (int i = 0; i < KeenConstants.BulkBatchSize; i++)
                client.AddEvent("CachedEventTest", new { AProperty = "AValue" });

            Assert.DoesNotThrow(() => client.SendCachedEvents());
            Assert.Null(await client.EventCache.TryTake(), "Cache is empty");
            Assert.True( !UseMocks || ( total == KeenConstants.BulkBatchSize));
        }
开发者ID:kidchenko,项目名称:keen-sdk-net,代码行数:26,代码来源:KeenClientTest.cs

示例3: Caching_SendEvents_Success

        public async void 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) =>
                    {
                        if ((p == settingsEnv) 
                            && (null!=e.Property("CachedEventTest"))
                            && (e.Property("CachedEventTest").Value.Children().Count()==3))
                            return new List<CachedEvent>();
                        else
                            throw new Exception("Unexpected value");
                    }));

            client.AddEvent("CachedEventTest", new { AProperty = "AValue" });
            client.AddEvent("CachedEventTest", new { AProperty = "AValue" });
            client.AddEvent("CachedEventTest", new { AProperty = "AValue" });

            Assert.DoesNotThrow(() => client.SendCachedEvents());
            Assert.Null(await client.EventCache.TryTake(), "Cache is empty");
        }
开发者ID:kidchenko,项目名称:keen-sdk-net,代码行数:22,代码来源:KeenClientTest.cs

示例4: Caching_SendEmptyEvents_Success

 public void Caching_SendEmptyEvents_Success()
 {
     var client = new KeenClient(settingsEnv, new EventCacheMemory());
     Assert.DoesNotThrow(() => client.SendCachedEvents());
 }
开发者ID:kidchenko,项目名称:keen-sdk-net,代码行数:5,代码来源:KeenClientTest.cs

示例5: 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

示例6: CachingPCL_SendEmptyEvents_Success

 public void CachingPCL_SendEmptyEvents_Success(IEventCache cache)
 {
     var client = new KeenClient(settingsEnv, cache);
     Assert.DoesNotThrow(() => client.SendCachedEvents());
 }
开发者ID:kidchenko,项目名称:keen-sdk-net,代码行数:5,代码来源:EventCacheTest.cs


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