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


C# KeenClient.AddGlobalProperty方法代码示例

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


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

示例1: AddGlobalProperty_DelegateValueProviderNullReturn_Throws

        public void AddGlobalProperty_DelegateValueProviderNullReturn_Throws()
        {
            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>() == "AValue")
                            && (e["AGlobal"].Value<string>() == "value"))
                            return;
                        else
                            throw new Exception("Unexpected value");
                    }));

            var i = 0;
            // return valid for the first two tests, then null
            client.AddGlobalProperty("AGlobal", new DynamicPropertyValue(() => i++ > 1 ? null : "value"));
            // This is the second test (AddGlobalProperty runs the first)
            Assert.DoesNotThrow(() => client.AddEvent("AddEventTest", new { AProperty = "AValue" }));
            // Third test should fail.
            Assert.Throws<KeenException>(() => { client.AddEvent("AddEventTest", new { AProperty = "AValue" }); });
        }
开发者ID:kidchenko,项目名称:keen-sdk-net,代码行数:23,代码来源:KeenClientTest.cs

示例2: AddGlobalProperty_DelegateValueProviderThrows_Throws

 public void AddGlobalProperty_DelegateValueProviderThrows_Throws()
 {
     var client = new KeenClient(settingsEnv);
     Assert.Throws<KeenException>(() => client.AddGlobalProperty("AGlobal", new DynamicPropertyValue(() => { throw new Exception("test exception"); })));
 }
开发者ID:kidchenko,项目名称:keen-sdk-net,代码行数:5,代码来源:KeenClientTest.cs

示例3: AddGlobalProperty_DelegateNullDynamicValue_Throws

 public void AddGlobalProperty_DelegateNullDynamicValue_Throws()
 {
     var client = new KeenClient(settingsEnv);
     Assert.Throws<KeenException>(() => { client.AddGlobalProperty("AGlobal", new DynamicPropertyValue(() => null)); });
 }
开发者ID:kidchenko,项目名称:keen-sdk-net,代码行数:5,代码来源:KeenClientTest.cs

示例4: AddGlobalProperty_DelegateNullValueProvider_Throws

 public void AddGlobalProperty_DelegateNullValueProvider_Throws()
 {
     var client = new KeenClient(settingsEnv);
     Assert.Throws<KeenException>(() => { client.AddGlobalProperty("AGlobal", null); });
 }
开发者ID:kidchenko,项目名称:keen-sdk-net,代码行数:5,代码来源:KeenClientTest.cs

示例5: AddGlobalProperty_DelegateObjectValue_Success

        public void AddGlobalProperty_DelegateObjectValue_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>() == "AValue") 
                            && (e["AGlobal"].Value<JObject>()["SubProp1"].Value<string>() == "Value"))
                            return;
                        else
                            throw new Exception("Unexpected value");
                    }));

            Assert.DoesNotThrow(() =>
            {
                client.AddGlobalProperty("AGlobal", new DynamicPropertyValue(() => new { SubProp1 = "Value", SubProp2 = "Value" }));
                client.AddEvent("AddEventTest", new { AProperty = "AValue" });
            });
        }
开发者ID:kidchenko,项目名称:keen-sdk-net,代码行数:21,代码来源:KeenClientTest.cs

示例6: AddGlobalProperty_CollectionValue_Success

        public void AddGlobalProperty_CollectionValue_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>() == "AValue")
                            && (e["AGlobal"].Values<int>().All((x) => (x == 1) || (x == 2) || (x == 3))))
                            return;
                        else
                            throw new Exception("Unexpected value");
                    }));

            Assert.DoesNotThrow(() =>
            {
                client.AddGlobalProperty("AGlobal", new[] { 1, 2, 3, });
                client.AddEvent("AddEventTest", new { AProperty = "AValue" });
            });
        }
开发者ID:kidchenko,项目名称:keen-sdk-net,代码行数:21,代码来源:KeenClientTest.cs

示例7: AddGlobalProperty_InvalidValueNameBlank_Throws

 public void AddGlobalProperty_InvalidValueNameBlank_Throws()
 {
     var client = new KeenClient(settingsEnv);
     Assert.Throws<KeenException>(() => client.AddGlobalProperty("", "AValue"));
 }
开发者ID:kidchenko,项目名称:keen-sdk-net,代码行数:5,代码来源:KeenClientTest.cs

示例8: AddGlobalProperty_InvalidValueNameLength_Throws

 public void AddGlobalProperty_InvalidValueNameLength_Throws()
 {
     var client = new KeenClient(settingsEnv);
     Assert.Throws<KeenException>(() => client.AddGlobalProperty(new String('A', 256), "AValue"));
 }
开发者ID:kidchenko,项目名称:keen-sdk-net,代码行数:5,代码来源:KeenClientTest.cs

示例9: AddGlobalProperty_DelegateSimpleValue_Success

        public void AddGlobalProperty_DelegateSimpleValue_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>() == "AValue")
                            && (e["AGlobal"]!=null))
                            return;
                        else
                            throw new Exception("Unexpected value");
                    }));

            Assert.DoesNotThrow(() =>
            {
                client.AddGlobalProperty("AGlobal", new DynamicPropertyValue(() => DateTime.Now.Millisecond));
                client.AddEvent("AddEventTest", new { AProperty = "AValue" });
                client.AddEvent("AddEventTest", new { AProperty = "AValue" });
            });
        }
开发者ID:keenlabs,项目名称:keen-sdk-net,代码行数:22,代码来源:KeenClientTest.cs


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