public OpenKitInitializer(IOpenKitBuilder builder)
        {
            logger = builder.Logger;
            privacyConfiguration = PrivacyConfiguration.From(builder);
            openKitConfiguration = OpenKitConfiguration.From(builder);

            timingProvider    = new DefaultTimingProvider();
            threadIdProvider  = new DefaultThreadIdProvider();
            sessionIdProvider = new DefaultSessionIdProvider();

            beaconCache        = new BeaconCache(logger);
            beaconCacheEvictor = new BeaconCacheEvictor(logger, beaconCache, BeaconCacheConfiguration.From(builder),
                                                        timingProvider);

            var httpClientConfig = HttpClientConfiguration.From(openKitConfiguration);
            // shared thread suspender between BeaconSender and HttpClient. HttpClient will be woken up when
            // BeaconSender shuts down
            var beaconSenderThreadSuspender = new InterruptibleThreadSuspender();

            beaconSender = new BeaconSender(
                logger,
                httpClientConfig,
                new DefaultHttpClientProvider(logger, beaconSenderThreadSuspender),
                timingProvider,
                beaconSenderThreadSuspender);
            var watchdogThreadSuspender = new InterruptibleThreadSuspender();

            sessionWatchdog = new SessionWatchdog(
                logger,
                new SessionWatchdogContext(timingProvider, watchdogThreadSuspender));
        }
Example #2
0
        public void SetUp()
        {
            mockLogger = Substitute.For <ILogger>();
            mockLogger.IsInfoEnabled.Returns(true);
            mockLogger.IsDebugEnabled.Returns(true);

            mockPrivacyConfig = Substitute.For <IPrivacyConfiguration>();
            mockPrivacyConfig.DataCollectionLevel.Returns(ConfigurationDefaults.DefaultDataCollectionLevel);
            mockPrivacyConfig.CrashReportingLevel.Returns(ConfigurationDefaults.DefaultCrashReportingLevel);

            mockOpenKitConfig = Substitute.For <IOpenKitConfiguration>();
            mockOpenKitConfig.ApplicationId.Returns(AppId);
            mockOpenKitConfig.DeviceId.Returns(DeviceId);
            mockOpenKitConfig.ApplicationName.Returns(AppName);
            mockOpenKitConfig.OperatingSystem.Returns(string.Empty);
            mockOpenKitConfig.Manufacturer.Returns(string.Empty);
            mockOpenKitConfig.ModelId.Returns(string.Empty);

            mockTimingProvider     = Substitute.For <ITimingProvider>();
            mockThreadIdProvider   = Substitute.For <IThreadIdProvider>();
            mockSessionIdProvider  = Substitute.For <ISessionIdProvider>();
            mockBeaconCache        = Substitute.For <IBeaconCache>();
            mockBeaconSender       = Substitute.For <IBeaconSender>();
            mockBeaconCacheEvictor = Substitute.For <IBeaconCacheEvictor>();
            mockSessionWatchdog    = Substitute.For <ISessionWatchdog>();
        }
 public TestOpenKitBuilder()
 {
     logger             = Substitute.For <ILogger>();
     privacyConfig      = Substitute.For <IPrivacyConfiguration>();
     openKitConfig      = Substitute.For <IOpenKitConfiguration>();
     threadIdProvider   = Substitute.For <IThreadIdProvider>();
     timingProvider     = Substitute.For <ITimingProvider>();
     sessionIdProvider  = Substitute.For <ISessionIdProvider>();
     beaconCache        = Substitute.For <IBeaconCache>();
     beaconSender       = Substitute.For <IBeaconSender>();
     beaconCacheEvictor = Substitute.For <IBeaconCacheEvictor>();
     sessionWatchdog    = Substitute.For <ISessionWatchdog>();
 }
Example #4
0
        /// <summary>
        /// Constructor for creating an OpenKit instance.
        /// </summary>
        /// <param name="initializer">provider to get all OpenKit related configuration parameters.</param>
        internal OpenKit(IOpenKitInitializer initializer)
        {
            logger = initializer.Logger;
            privacyConfiguration = initializer.PrivacyConfiguration;
            openKitConfiguration = initializer.OpenKitConfiguration;

            timingProvider    = initializer.TimingProvider;
            threadIdProvider  = initializer.ThreadIdProvider;
            sessionIdProvider = initializer.SessionIdProvider;

            beaconCache        = initializer.BeaconCache;
            beaconCacheEvictor = initializer.BeaconCacheEvictor;

            beaconSender    = initializer.BeaconSender;
            sessionWatchdog = initializer.SessionWatchdog;

            LogOpenKitInstanceCreation(logger, openKitConfiguration);
        }
 internal TestOpenKitBuilder With(IBeaconCacheEvictor evictor)
 {
     beaconCacheEvictor = evictor;
     return(this);
 }