public void AddsItselfToTelemetryInitializersToSetSessionIdForAllTelemetryTypes() { ServiceLocator.AddService <IApplicationService>(new ApplicationService()); var module = new SessionTelemetryModule(new StubPlatform(), new StubClock()); var configuration = new TelemetryConfiguration(); configuration.TelemetryChannel = new InMemoryChannel(); module.Initialize(); Assert.Contains(module, TelemetryConfiguration.Active.TelemetryInitializers); }
public void InitializeSetsSessionIdOfGivenTelemetryAfterApplicationIsStarted() { SessionTelemetryModule module = this.CreateSessionTelemetryModule(); module.Initialize(); var telemetry = new StubTelemetry(); ((ITelemetryInitializer)module).Initialize(telemetry); Assert.NotEmpty(telemetry.Context.Session.Id); }
public void InitializePreservesExistingIsFirstSessionOfGivenTelemetry() { SessionTelemetryModule module = this.CreateSessionTelemetryModule(); module.Initialize(); var telemetry = new StubTelemetry(); telemetry.Context.Session.IsFirst = false; ((ITelemetryInitializer)module).Initialize(telemetry); Assert.Equal(false, telemetry.Context.Session.IsFirst); }
public void InitializeDoesNotSetSessionIsFirstWhenPreviousSessionTimedOut() { SessionTelemetryModule module = this.CreateSessionTelemetryModule(); // Application started and suspended 1 day ago this.clock.Time = DateTimeOffset.Now - TimeSpan.FromDays(1); module.Initialize(); module.HandleApplicationStoppingEvent(null, null); // Application resumes today this.clock.Time = DateTimeOffset.Now; module.HandleApplicationStartedEvent(null, null); var telemetry = new StubTelemetry(); ((ITelemetryInitializer)module).Initialize(telemetry); Assert.Null(telemetry.Context.Session.IsFirst); }
public void AddsItselfToTelemetryInitializersToSetSessionIdForAllTelemetryTypes() { ServiceLocator.AddService<IApplicationService>(new ApplicationService()); var module = new SessionTelemetryModule(new StubPlatform(), new StubClock()); var configuration = new TelemetryConfiguration(); configuration.TelemetryChannel = new InMemoryChannel(); module.Initialize(); Assert.Contains(module, TelemetryConfiguration.Active.TelemetryInitializers); }