public void SetUp() { mockLogger = Substitute.For <ILogger>(); mockOpenKitConfiguration = Substitute.For <IOpenKitConfiguration>(); mockOpenKitConfiguration.ApplicationId.Returns(string.Empty); mockOpenKitConfiguration.ApplicationName.Returns(string.Empty); mockOpenKitConfiguration.ApplicationVersion.Returns(string.Empty); mockOpenKitConfiguration.DeviceId.Returns(DeviceId); mockPrivacyConfiguration = Substitute.For <IPrivacyConfiguration>(); mockBeaconCache = Substitute.For <IBeaconCache>(); mockSessionIdProvider = Substitute.For <ISessionIdProvider>(); mockThreadIdProvider = Substitute.For <IThreadIdProvider>(); mockTimingProvider = Substitute.For <ITimingProvider>(); mockParent = Substitute.For <IOpenKitComposite>(); mockInput = Substitute.For <ISessionCreatorInput>(); mockInput.Logger.Returns(mockLogger); mockInput.OpenKitConfiguration.Returns(mockOpenKitConfiguration); mockInput.PrivacyConfiguration.Returns(mockPrivacyConfiguration); mockInput.BeaconCache.Returns(mockBeaconCache); mockInput.SessionIdProvider.Returns(mockSessionIdProvider); mockInput.ThreadIdProvider.Returns(mockThreadIdProvider); mockInput.TimingProvider.Returns(mockTimingProvider); mockInput.CurrentServerId.Returns(ServerId); }
protected OpenKit(ILogger logger, OpenKitConfiguration configuration, IHTTPClientProvider httpClientProvider, ITimingProvider timingProvider, IThreadIDProvider threadIDProvider) { if (logger.IsInfoEnabled) { //TODO: Use proper version information (incl. the build number) logger.Info(configuration.OpenKitType + " " + GetType().Name + " " + OpenKitConstants.DEFAULT_APPLICATION_VERSION + " instantiated"); } if (logger.IsDebugEnabled) { logger.Debug( "applicationName=" + configuration.ApplicationName + ", applicationID=" + configuration.ApplicationID + ", deviceID=" + configuration.DeviceID + ", endpointURL=" + configuration.EndpointURL ); } this.configuration = configuration; this.logger = logger; this.timingProvider = timingProvider; this.threadIDProvider = threadIDProvider; beaconCache = new BeaconCache(logger); beaconSender = new BeaconSender(logger, configuration, httpClientProvider, timingProvider); beaconCacheEvictor = new BeaconCacheEvictor(logger, beaconCache, configuration.BeaconCacheConfig, timingProvider); }
public void SetUp() { mockLogger = Substitute.For <ILogger>(); mockBeaconCache = Substitute.For <IBeaconCache>(); mockTimingProvider = Substitute.For <ITimingProvider>(); isShutdownFunc = () => false; }
public void Setup() { logger = Substitute.For <ILogger>(); config = new TestConfiguration(); clientProvider = Substitute.For <IHTTPClientProvider>(); timingProvider = Substitute.For <ITimingProvider>(); }
public void Setup() { currentTime = 1; newSessions = new List <SessionWrapper>(); openSessions = new List <SessionWrapper>(); finishedSessions = new List <SessionWrapper>(); // http client httpClient = Substitute.For <IHTTPClient>(); // provider timingProvider = Substitute.For <ITimingProvider>(); timingProvider.ProvideTimestampInMilliseconds().Returns(x => { return(++currentTime); }); // every access is a tick httpClientProvider = Substitute.For <IHTTPClientProvider>(); httpClientProvider.CreateClient(Arg.Any <HTTPClientConfiguration>()).Returns(x => httpClient); // context context = Substitute.For <IBeaconSendingContext>(); context.HTTPClientProvider.Returns(x => httpClientProvider); context.GetHTTPClient().Returns(x => httpClient); context.IsCaptureOn.Returns(true); // beacon sender logger = Substitute.For <ILogger>(); beaconSender = new BeaconSender(logger, config, httpClientProvider, timingProvider); // current time getter context.CurrentTimestamp.Returns(x => timingProvider.ProvideTimestampInMilliseconds()); // sessions context.NewSessions.Returns(newSessions); context.OpenAndConfiguredSessions.Returns(openSessions); context.FinishedAndConfiguredSessions.Returns(finishedSessions); }
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)); }
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 void Setup() { config = new TestConfiguration(); clientProvider = Substitute.For <IHTTPClientProvider>(); timingProvider = Substitute.For <ITimingProvider>(); nonTerminalStateMock = Substitute.For <AbstractBeaconSendingState>(false); }
public void Setup() { httpClient = Substitute.For <IHTTPClient>(); newSessions = new List <SessionWrapper>(); openSessions = new List <SessionWrapper>(); finishedSessions = new List <SessionWrapper>(); // provider timingProvider = Substitute.For <ITimingProvider>(); httpClientProvider = Substitute.For <IHTTPClientProvider>(); httpClientProvider.CreateClient(Arg.Any <HTTPClientConfiguration>()).Returns(x => httpClient); // context context = Substitute.For <IBeaconSendingContext>(); context.GetHTTPClient().Returns(httpClient); context.HTTPClientProvider.Returns(httpClientProvider); // beacon sender var logger = Substitute.For <ILogger>(); beaconSender = new BeaconSender(logger, context); // sessions context.NewSessions.Returns(newSessions); context.OpenAndConfiguredSessions.Returns(openSessions); context.FinishedAndConfiguredSessions.Returns(finishedSessions); }
public Queue(IServiceProvider serviceProvider, string queueName) { _messagingProvider = serviceProvider.GetService <IReliableMessaging>(); _timingProvider = serviceProvider.GetService <ITimingProvider>(); _dataProvider = serviceProvider.GetService <IQueueDepthRepository>(); _queueName = queueName; }
public void SetupIdGenerator() { var logger = Substitute.For <ILogger <IdGenerator> >(); _timingProvider = Substitute.For <ITimingProvider>(); _generator = new IdGenerator(_timingProvider, logger); }
// *** constructor *** /// <summary> /// Creates a new instance of type Beacon /// </summary> /// <param name="logger">Logger for logging messages</param> /// <param name="cache">Cache storing beacon related data</param> /// <param name="configuration">OpenKit related configuration</param> /// <param name="clientIPAddress">The client's IP address</param> /// <param name="threadIdProvider">Provider for retrieving thread id</param> /// <param name="timingProvider">Provider for time related methods</param> public Beacon(ILogger logger, BeaconCache beaconCache, OpenKitConfiguration configuration, string clientIPAddress, IThreadIDProvider threadIDProvider, ITimingProvider timingProvider) { this.logger = logger; this.beaconCache = beaconCache; this.sessionNumber = configuration.NextSessionNumber; this.timingProvider = timingProvider; this.configuration = configuration; this.threadIDProvider = threadIDProvider; this.sessionStartTime = timingProvider.ProvideTimestampInMilliseconds(); if (InetAddressValidator.IsValidIP(clientIPAddress)) { this.clientIPAddress = clientIPAddress; } else { this.clientIPAddress = string.Empty; } // store the current http configuration this.httpConfiguration = configuration.HTTPClientConfig; basicBeaconData = CreateBasicBeaconData(); }
public SeptentrioSerial(string comPort, int baud, SensorPose sensorPose, ITimingProvider timingProvider) { rxSerial = new SerialPort(comPort, baud); foreach (string p in SerialPort.GetPortNames()) Console.WriteLine(p); rxSerial.DataReceived += new SerialDataReceivedEventHandler(rxSerial_DataReceived); this.sensorPose = sensorPose; this.timingProvider = timingProvider; }
internal TimeEvictionStrategy(ILogger logger, IBeaconCache beaconCache, IBeaconCacheConfiguration configuration, ITimingProvider timingProvider, Func <bool> isShutdownFunc) { this.logger = logger; this.beaconCache = beaconCache; this.configuration = configuration; this.timingProvider = timingProvider; this.isShutdownFunc = isShutdownFunc; LastRunTimestamp = -1; }
public void SetUp() { mockTimingProvider = Substitute.For <ITimingProvider>(); beacon = new Beacon(Substitute.For <ILogger>(), new BeaconCache(), new TestConfiguration(), "127.0.0.1", Substitute.For <IThreadIDProvider>(), mockTimingProvider); }
internal TestBeaconBuilder() { logger = Substitute.For <ILogger>(); beaconCache = Substitute.For <IBeaconCache>(); clientIpAddress = "127.0.0.1"; sessionIdProvider = Substitute.For <ISessionIdProvider>(); threadIdProvider = Substitute.For <IThreadIdProvider>(); timingProvider = Substitute.For <ITimingProvider>(); randomGenerator = Substitute.For <IPrnGenerator>(); }
/// <summary> /// Constructor /// /// Current state is initialized to <see cref="Dynatrace.OpenKit.Core.Communication."/> /// /// </summary> /// <param name="logger"></param> /// <param name="configuration"></param> /// <param name="httpClientProvider"></param> /// <param name="timingProvider"></param> public BeaconSendingContext(ILogger logger, OpenKitConfiguration configuration, IHTTPClientProvider httpClientProvider, ITimingProvider timingProvider) { this.logger = logger; Configuration = configuration; HTTPClientProvider = httpClientProvider; TimingProvider = timingProvider; // set current state to init state CurrentState = new BeaconSendingInitState(); }
public void SetUp() { mockTimingProvider = Substitute.For <ITimingProvider>(); mockSession = Substitute.For <ISessionInternals>(); mockThreadSuspender = Substitute.For <IInterruptibleThreadSuspender>(); mockThreadSuspender.Sleep(Arg.Any <int>()).Returns(true); mockSessionProxy = Substitute.For <ISessionProxy>(); }
/// <summary> /// Constructor /// /// Current state is initialized to <see cref="Dynatrace.OpenKit.Core.Communication.BeaconSendingInitState"/>. /// </summary> internal BeaconSendingContext( ILogger logger, IHttpClientConfiguration httpClientConfiguration, IHttpClientProvider httpClientProvider, ITimingProvider timingProvider, IInterruptibleThreadSuspender threadSuspender ) : this(logger, httpClientConfiguration, httpClientProvider, timingProvider, threadSuspender, new BeaconSendingInitState()) { }
public SeptentrioSerial(string comPort, int baud, SensorPose sensorPose, ITimingProvider timingProvider) { rxSerial = new SerialPort(comPort, baud); foreach (string p in SerialPort.GetPortNames()) { Console.WriteLine(p); } rxSerial.DataReceived += new SerialDataReceivedEventHandler(rxSerial_DataReceived); this.sensorPose = sensorPose; this.timingProvider = timingProvider; }
internal BeaconSender( ILogger logger, IHttpClientConfiguration httpClientConfiguration, IHttpClientProvider clientProvider, ITimingProvider timingProvider, IInterruptibleThreadSuspender threadSuspender) { this.logger = logger; context = new BeaconSendingContext(logger, httpClientConfiguration, clientProvider, timingProvider, threadSuspender); }
public void SetUp() { mockTimingProvider = Substitute.For <ITimingProvider>(); testConfiguration = new TestConfiguration(); beacon = new Beacon(Substitute.For <ILogger>(), new BeaconCache(), testConfiguration, "127.0.0.1", Substitute.For <IThreadIDProvider>(), mockTimingProvider); action = new RootAction(beacon, "ActionName", new SynchronizedQueue <IAction>()); }
public void SetUp() { logger = Substitute.For <ILogger>(); logger.IsDebugEnabled.Returns(true); beaconSendingContext = Substitute.For <IBeaconSendingContext>(); beaconSender = new BeaconSender(beaconSendingContext); mockTimingProvider = Substitute.For <ITimingProvider>(); var configuration = new TestConfiguration(); beacon = new Beacon(logger, new Caching.BeaconCache(), configuration, "127.0.0.1", Substitute.For <IThreadIDProvider>(), mockTimingProvider); }
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>(); }
public void SetUp() { logger = Substitute.For <ILogger>(); mockTimingProvider = Substitute.For <ITimingProvider>(); var beaconConfig = new BeaconConfiguration(1, DataCollectionLevel.USER_BEHAVIOR, CrashReportingLevel.OPT_IN_CRASHES); testConfiguration = new TestConfiguration("1", beaconConfig); beacon = new Beacon(logger, new BeaconCache(logger), testConfiguration, "127.0.0.1", Substitute.For <IThreadIDProvider>(), mockTimingProvider); }
/// <summary> /// Constructor /// /// Current state is initialized to <see cref="Dynatrace.OpenKit.Core.Communication."/> /// /// </summary> /// <param name="configuration"></param> /// <param name="httpClientProvider"></param> /// <param name="timingProvider"></param> public BeaconSendingContext(OpenKitConfiguration configuration, IHTTPClientProvider httpClientProvider, ITimingProvider timingProvider) { Configuration = configuration; HTTPClientProvider = httpClientProvider; TimingProvider = timingProvider; // set time sync supported to true IsTimeSyncSupported = true; // set last time sync time to -1 LastTimeSyncTime = -1; // set current state to init state CurrentState = new BeaconSendingInitState(); }
protected OpenKit(ILogger logger, OpenKitConfiguration configuration, IHTTPClientProvider httpClientProvider, ITimingProvider timingProvider, IThreadIDProvider threadIDProvider) { this.configuration = configuration; this.logger = logger; this.timingProvider = timingProvider; this.threadIDProvider = threadIDProvider; beaconCache = new BeaconCache(); beaconSender = new BeaconSender(configuration, httpClientProvider, timingProvider); beaconCacheEvictor = new BeaconCacheEvictor(logger, beaconCache, configuration.BeaconCacheConfig, timingProvider); }
/// <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); }
public void Setup() { currentTime = 1; lastTimeSyncTime = 1; newSessions = new List <SessionWrapper>(); openSessions = new List <SessionWrapper>(); finishedSessions = new List <SessionWrapper>(); // http client httpClient = Substitute.For <IHTTPClient>(); // provider timingProvider = Substitute.For <ITimingProvider>(); timingProvider.ProvideTimestampInMilliseconds().Returns(x => { return(++currentTime); }); // every access is a tick httpClientProvider = Substitute.For <IHTTPClientProvider>(); httpClientProvider.CreateClient(Arg.Any <HTTPClientConfiguration>()).Returns(x => httpClient); // context context = Substitute.For <IBeaconSendingContext>(); context.HTTPClientProvider.Returns(x => httpClientProvider); context.GetHTTPClient().Returns(x => httpClient); context.LastTimeSyncTime.Returns(x => currentTime); // always return the current time to prevent re-sync context.IsCaptureOn.Returns(true); // beacon sender var logger = Substitute.For <ILogger>(); beaconSender = new BeaconSender(logger, config, httpClientProvider, timingProvider); // return true by default context.IsTimeSyncSupported.Returns(true); // current time getter context.CurrentTimestamp.Returns(x => timingProvider.ProvideTimestampInMilliseconds()); // last time sycn getter + setter context.LastTimeSyncTime = Arg.Do <long>(x => lastTimeSyncTime = x); context.LastTimeSyncTime = lastTimeSyncTime; // sessions context.NewSessions.Returns(newSessions); context.OpenAndConfiguredSessions.Returns(openSessions); context.FinishedAndConfiguredSessions.Returns(finishedSessions); }
internal SessionProxy( ILogger logger, IOpenKitComposite parent, ISessionCreator sessionCreator, ITimingProvider timingProvider, IBeaconSender beaconSender, ISessionWatchdog sessionWatchdog) { this.logger = logger; this.parent = parent; this.sessionCreator = sessionCreator; this.timingProvider = timingProvider; this.beaconSender = beaconSender; this.sessionWatchdog = sessionWatchdog; var currentServerConfig = beaconSender.LastServerConfiguration; CreateInitialSessionAndMakeCurrent(currentServerConfig); }
internal BeaconSendingContext( ILogger logger, IHttpClientConfiguration httpClientConfiguration, IHttpClientProvider httpClientProvider, ITimingProvider timingProvider, IInterruptibleThreadSuspender threadSuspender, AbstractBeaconSendingState initialState ) { this.logger = logger; this.httpClientConfiguration = httpClientConfiguration; serverConfiguration = ServerConfiguration.Default; HttpClientProvider = httpClientProvider; this.timingProvider = timingProvider; this.threadSuspender = threadSuspender; lastResponseAttributes = ResponseAttributes.WithUndefinedDefaults().Build(); CurrentState = initialState; }