public void SetCustomProperties()
        {
            var settingsMock = new Mock <IApplicationSettings>();

            settingsMock.Setup(settings => settings.GetValue(MobileCenter.EnabledKey, true)).Returns(true);
            var channelGroupMock = new Mock <IChannelGroup>();
            var channelUnitMock  = new Mock <IChannelUnit>();

            channelGroupMock.Setup(
                group => group.AddChannel(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <TimeSpan>(), It.IsAny <int>()))
            .Returns(channelUnitMock.Object);
            MobileCenter.Instance = new MobileCenter(settingsMock.Object, new MockChannelGroupFactory(channelGroupMock));
            MobileCenter.Configure("appsecret");

            /* Set null. */
            MobileCenter.SetCustomProperties(null);
            channelUnitMock.Verify(channel => channel.Enqueue(It.IsAny <Log>()), Times.Never());

            /* Set empty. */
            var empty = new CustomProperties();

            MobileCenter.SetCustomProperties(empty);
            channelUnitMock.Verify(channel => channel.Enqueue(It.IsAny <Log>()), Times.Never());

            /* Set normal. */
            var properties = new CustomProperties();

            properties.Set("test", "test");
            MobileCenter.SetCustomProperties(properties);
            channelUnitMock.Verify(channel => channel.Enqueue(It.Is <CustomPropertiesLog>(log =>
                                                                                          log.Properties == properties.Properties)), Times.Once());
        }
        public void SetCustomProperties()
        {
            _settingsMock.Setup(settings => settings.GetValue(MobileCenter.EnabledKey, true)).Returns(true);
            var channelUnitMock = new Mock <IChannelUnit>();

            _channelGroupMock.Setup(
                group => group.AddChannel(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <TimeSpan>(), It.IsAny <int>()))
            .Returns(channelUnitMock.Object);

            // Set before Mobile Center is configured.
            MobileCenter.SetCustomProperties(new CustomProperties());
            channelUnitMock.Verify(channel => channel.EnqueueAsync(It.IsAny <Log>()), Times.Never());

            MobileCenter.Configure("appsecret");

            // Set null.
            MobileCenter.SetCustomProperties(null);
            channelUnitMock.Verify(channel => channel.EnqueueAsync(It.IsAny <Log>()), Times.Never());

            // Set empty.
            var empty = new CustomProperties();

            MobileCenter.SetCustomProperties(empty);
            channelUnitMock.Verify(channel => channel.EnqueueAsync(It.IsAny <Log>()), Times.Never());

            // Set normal.
            var properties = new CustomProperties();

            properties.Set("test", "test");
            MobileCenter.SetCustomProperties(properties);
            channelUnitMock.Verify(channel => channel.EnqueueAsync(It.Is <CustomPropertiesLog>(log =>
                                                                                               log.Properties == properties.Properties)), Times.Once());
        }
        private void Send_Clicked(object sender, EventArgs e)
        {
            CustomProperties customProperties = new CustomProperties();

            foreach (var customProperty in PropertiesContainer.Children)
            {
                (customProperty as CustomPropertyView).AddCustomProperty(customProperties);
            }
            MobileCenter.SetCustomProperties(customProperties);
        }
Beispiel #4
0
        async void OnSaveClicked(object sender, EventArgs e)
        {
            var todoItem = (TodoItem)BindingContext;
            await App.Database.SaveItemAsync(todoItem);

            CustomProperties properties = new CustomProperties();

            properties.Set("ItemName", todoItem.Name);
            MobileCenter.SetCustomProperties(properties);

            await Navigation.PopAsync();
        }
Beispiel #5
0
        public static async Task Start(string appSecret)
        {
            MobileCenter.Start(appSecret, typeof(Analytics), typeof(Crashes), typeof(Distribute), typeof(Push));
#if DEBUG
            await Distribute.SetEnabledAsync(false);
#else
            await Distribute.SetEnabledAsync(true);
#endif
            await Analytics.SetEnabledAsync(true);

            var customprops = new CustomProperties();
            customprops.Set("username", "mahdi");
            MobileCenter.SetCustomProperties(customprops);
        }
Beispiel #6
0
        protected void SetProperty(string key, string value)
        {
            var prop = new CustomProperties();

            if (string.IsNullOrEmpty(value))
            {
                prop.Clear(key);
            }
            else
            {
                prop.Set(key, value);
            }

            MobileCenter.SetCustomProperties(prop);
        }