Ejemplo n.º 1
0
 public void StartInstanceWithConfigure()
 {
     AppCenter.Configure("appsecret");
     AppCenter.Start(typeof(MockAppCenterService));
     MockAppCenterService.Mock.Verify(
         service => service.OnChannelGroupReady(It.IsAny <IChannelGroup>(), It.IsAny <string>()), Times.Once());
 }
Ejemplo n.º 2
0
        public void SetCustomProperties()
        {
            _settingsMock.Setup(settings => settings.GetValue(AppCenter.EnabledKey, It.IsAny <bool>()))
            .Returns(true);

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

            AppCenter.Configure("appsecret");

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

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

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

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

            properties.Set("test", "test");
            AppCenter.SetCustomProperties(properties);
            _channelMock.Verify(channel => channel.EnqueueAsync(It.Is <CustomPropertyLog>(log =>
                                                                                          log.Properties == properties.Properties)), Times.Once());
        }
Ejemplo n.º 3
0
        public void TestIsNetworkRequestsAllowed()
        {
            AppCenter.Configure("appsecret");

            // Verify setting true value when previous value is true.
            _settingsMock.Setup(settings => settings.GetValue(AppCenter.AllowedNetworkRequestsKey, It.IsAny <bool>()))
            .Returns(true);
            AppCenter.IsNetworkRequestsAllowed = true;
            _channelGroupMock.Verify(groups => groups.SetNetworkRequestAllowed(It.IsAny <bool>()), Times.Never());

            // Verify setting false value when previous value is false.
            _settingsMock.Setup(settings => settings.GetValue(AppCenter.AllowedNetworkRequestsKey, It.IsAny <bool>()))
            .Returns(false);
            AppCenter.IsNetworkRequestsAllowed = false;
            _channelGroupMock.Verify(groups => groups.SetNetworkRequestAllowed(It.IsAny <bool>()), Times.Never());

            // Verify setting true value when previous value is false.
            _settingsMock.Setup(settings => settings.GetValue(AppCenter.AllowedNetworkRequestsKey, It.IsAny <bool>()))
            .Returns(false);
            AppCenter.IsNetworkRequestsAllowed = true;
            _channelGroupMock.Verify(groups => groups.SetNetworkRequestAllowed(true));

            // Verify setting false value when previous value is true.
            _settingsMock.Setup(settings => settings.GetValue(AppCenter.AllowedNetworkRequestsKey, It.IsAny <bool>()))
            .Returns(true);
            AppCenter.IsNetworkRequestsAllowed = false;
            _channelGroupMock.Verify(groups => groups.SetNetworkRequestAllowed(false));
        }
 public void start(string appId)
 {
     RunOnDispatcher(async() =>
     {
         try
         {
             bool isEnabled    = await AppCenter.IsEnabledAsync();
             bool isConfigured = AppCenter.Configured;
             if (isConfigured == false)
             {
                 AppCenter.Configure(appId);
                 AppCenter.Start(typeof(Analytics));
             }
             else
             {
                 if (isEnabled == false)
                 {
                     await AppCenter.SetEnabledAsync(true);
                 }
             }
         }
         catch (Exception e)
         {
             Debug.WriteLine(e.Message);
         }
     });
 }
Ejemplo n.º 5
0
        public void SetCustomProperties()
        {
            _settingsMock.Setup(settings => settings.GetValue(AppCenter.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 App Center is configured.
            AppCenter.SetCustomProperties(new CustomProperties());
            channelUnitMock.Verify(channel => channel.EnqueueAsync(It.IsAny <Log>()), Times.Never());

            AppCenter.Configure("appsecret");

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

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

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

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

            properties.Set("test", "test");
            AppCenter.SetCustomProperties(properties);
            channelUnitMock.Verify(channel => channel.EnqueueAsync(It.Is <CustomPropertyLog>(log =>
                                                                                             log.Properties == properties.Properties)), Times.Once());
        }
Ejemplo n.º 6
0
 public void SetLogLevelBeforeConfigure()
 {
     AppCenterLog.Level = LogLevel.Info;
     AppCenter.LogLevel = LogLevel.Assert;
     AppCenter.Configure("appsecret");
     Assert.AreEqual(LogLevel.Assert, AppCenter.LogLevel);
 }
Ejemplo n.º 7
0
        public void ConfigureAppCenterWithEmptyAppSecretEmptyResult()
        {
            var secrets = $"{AppCenter.PlatformIdentifier}=";

            AppCenter.Configure(secrets);

            Assert.IsFalse(AppCenter.Configured);
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            AppCenter.Configure("secret");
            AppCenter.Start(typeof(Analytics));


            Console.ReadKey();
        }
Ejemplo n.º 9
0
        public void Configure()
        {
            Assert.IsFalse(AppCenter.Configured);

            AppCenter.Configure("some string");

            Assert.IsTrue(AppCenter.Configured);
            _channelMock.Verify(channel => channel.SetEnabled(It.IsAny <bool>()));
        }
Ejemplo n.º 10
0
        public void VerifyPlatformId()
        {
            CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                AppCenter.Configure("uwp=appsecret");
            }).AsTask().GetAwaiter().GetResult();

            Assert.IsTrue(AppCenter.Configured);
        }
Ejemplo n.º 11
0
        public void GetConfigured()
        {
            var isConfiguredFirst = AppCenter.Configured;

            AppCenter.Configure("some string");

            Assert.IsFalse(isConfiguredFirst);
            Assert.IsTrue(AppCenter.Configured);
        }
Ejemplo n.º 12
0
        public void SetLogUrlAfterConfigure()
        {
            AppCenter.Configure("appsecret");
            var customLogUrl = "www dot log url dot com";

            AppCenter.SetLogUrl(customLogUrl);

            _channelGroupMock.Verify(channelGroup => channelGroup.SetLogUrl(customLogUrl), Times.Once());
        }
Ejemplo n.º 13
0
        public void GetNewInstallId()
        {
            AppCenter.Configure("appsecret");

            _settingsMock.ResetCalls();

            var installId = AppCenter.GetInstallIdAsync().Result;

            Assert.IsTrue(installId.HasValue);
            Assert.IsNotNull(installId.Value);
            _settingsMock.Verify(settings => settings.SetValue(AppCenter.InstallIdKey, It.IsNotNull <Guid?>()), Times.Once());
        }
Ejemplo n.º 14
0
        private static void SetUpAppCenter()
        {
            var countryCode = RegionInfo.CurrentRegion.TwoLetterISORegionName;

            AppCenter.SetCountryCode(countryCode);
            AppCenter.Configure("34c17fce-3c24-41cb-a48a-a570c781ea25");
            if (AppCenter.Configured)
            {
                AppCenter.Start(typeof(Analytics));
                AppCenter.Start(typeof(Crashes));
            }
        }
Ejemplo n.º 15
0
        public void GetEnabled()
        {
            AppCenter.Configure("appsecret");

            _settingsMock.ResetCalls();
            _settingsMock.SetupSequence(settings => settings.GetValue(AppCenter.EnabledKey, It.IsAny <bool>()))
            .Returns(true).Returns(false);

            Assert.IsTrue(AppCenter.IsEnabledAsync().Result);
            Assert.IsFalse(AppCenter.IsEnabledAsync().Result);
            _settingsMock.Verify(settings => settings.GetValue(AppCenter.EnabledKey, It.IsAny <bool>()),
                                 Times.Exactly(2));
        }
Ejemplo n.º 16
0
        public void StartServiceAfterUnhandledException()
        {
            AppCenter.Configure("uwp=appsecret");
            Assert.IsTrue(AppCenter.Configured);

            // Some exception occurred.
            ApplicationLifecycleHelper.Instance.InvokeUnhandledExceptionOccurred(null, new Exception());

            // Start any service.
            AppCenter.Start(typeof(TestAppCenterService));

            // No exception throws, just log message.
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Configures and starts the <see cref="AppCenter"/> SDK.
        /// </summary>
        private void LoadAppCenterSDK()
        {
            AppCenter.Configure("APP_CENTER_APP_SECRET");
            if (!AppCenter.Configured)
            {
                return;
            }

            if ((bool)UserSettings.Values["EnableDiagnostics"])
            {
                AppCenter.Start(typeof(Crashes));
            }
        }
Ejemplo n.º 18
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            AppCenter.Configure("b750cc7d-c006-44f4-ac96-511672277766");

#if DEBUG
            Xamarin.Calabash.Start();
#endif

            Forms.Init();
            LoadApplication(new App());

            return(base.FinishedLaunching(app, options));
        }
Ejemplo n.º 19
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();

            /* Code for starting up the Xamarin Test Cloud Agent */
#if ENABLE_TEST_CLOUD
            Xamarin.Calabash.Start();
#endif
            MSAnalytics.SetDelegate(new AnalyticsDelegate());
            AppCenter.Configure("f52dd054-e31f-4ff9-9f24-4e8d7942705b");

            LoadApplication(new App());

            return(base.FinishedLaunching(app, options));
        }
Ejemplo n.º 20
0
        public void StartServiceAfterUnhandledException()
        {
            AppCenter.Configure("uwp=appsecret");
            Assert.IsTrue(AppCenter.Configured);

            // Some exception occurred.
            ApplicationLifecycleHelper.Instance.InvokeUnhandledExceptionOccurred(null, new Exception());
            Task.Delay(100).Wait();

            // Start any service.
            AppCenter.Start(typeof(TestAppCenterService));

            // No exceptions are thrown.
            // System.Diagnostics.Debug.Listeners is not available here, so not able to verify that there are no errors in logs.
        }
Ejemplo n.º 21
0
        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);
            AppCenter.LogLevel = LogLevel.Verbose;
            AndroidAnalytics.SetListener(new AndroidAnalyticsListener());

            AppCenter.Configure("cc684d08-3240-4eb7-a748-e7ddd846a8b1");

            LoadApplication(new App());
        }
Ejemplo n.º 22
0
        public void GetInstallId()
        {
            AppCenter.Configure("appsecret");

            var fakeInstallId = Guid.NewGuid();

            _settingsMock.ResetCalls();
            _settingsMock.Setup(settings => settings.GetValue(AppCenter.InstallIdKey, It.IsAny <Guid>())).Returns(fakeInstallId);

            var installId = AppCenter.GetInstallIdAsync().Result;

            Assert.IsTrue(installId.HasValue);
            Assert.AreEqual(installId.Value, fakeInstallId);
            _settingsMock.Verify(settings => settings.GetValue(AppCenter.InstallIdKey, It.IsAny <Guid>()),
                                 Times.Once());
        }
Ejemplo n.º 23
0
        public void Test()
        {
            new EventAggregator().GetEvent <TestEvent>().Subscribe(arg => { });

            IContainerRegistry containerRegistry = null;

            INavigationService navgationService = null;

            containerRegistry.RegisterForNavigation(typeof(object), string.Empty);

            IDeviceService devService = null;

            devService.BeginInvokeOnMainThread(() => { });

            AppCenter.Configure(appSecret: "");
            Crashes.TrackError(exception: null);
            Analytics.TrackEvent(name: "");
        }
Ejemplo n.º 24
0
 public void LogUrlIsNotSetByDefault()
 {
     AppCenter.Configure("appsecret");
     _channelGroupMock.Verify(channelGroup => channelGroup.SetLogUrl(It.IsAny <string>()), Times.Never());
 }
Ejemplo n.º 25
0
 public void ConfigureWithEmptyAppSecret()
 {
     AppCenter.Configure("");
     Assert.IsFalse(AppCenter.Configured);
 }
Ejemplo n.º 26
0
 public void ConfigureWithNullAppSecret()
 {
     AppCenter.Configure(null);
     Assert.IsFalse(AppCenter.Configured);
 }
Ejemplo n.º 27
0
 public void VerifyPlatformId()
 {
     AppCenter.Configure("windowsdesktop=appsecret");
     Assert.IsTrue(AppCenter.Configured);
 }