Skip to content
This repository has been archived by the owner on Jun 10, 2020. It is now read-only.

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyMothra committed Apr 12, 2018
1 parent 9533849 commit fd1cdc8
Showing 1 changed file with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Microsoft.Extensions.DependencyInjection.Test
using System.Reflection;
using Logging;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.AspNetCore.DiagnosticListeners;
using Microsoft.ApplicationInsights.AspNetCore.Extensions;
using Microsoft.ApplicationInsights.AspNetCore.Logging;
using Microsoft.ApplicationInsights.AspNetCore.TelemetryInitializers;
Expand Down Expand Up @@ -565,6 +566,44 @@ public static void FallbacktoDefaultChannelWhenNoChannelFoundInDI()
Assert.Equal(typeof(InMemoryChannel), telemetryConfiguration.TelemetryChannel.GetType());
}


[Fact]
public static void VerifyTelemetryInitializerNoExceptionWhenAppIdProviderNotFoundFoundInDI()
{
// ARRANGE
var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor();
var config = new ConfigurationBuilder().AddApplicationInsightsSettings(endpointAddress: "http://localhost:1234/v2/track/").Build();
services.AddApplicationInsightsTelemetry(config);

services.AddSingleton<ITelemetryInitializer, ApplicationInsights.AspNetCore.TelemetryInitializers.OperationCorrelationTelemetryInitializer>();


IServiceProvider serviceProvider = services.BuildServiceProvider();
var operationCorrelationTelemetryInitializer = serviceProvider.GetService<ITelemetryInitializer>();

// SHOULD CALL ONINITIALIZE TELEMETRY
Assert.Equal(typeof(ApplicationInsights.AspNetCore.TelemetryInitializers.OperationCorrelationTelemetryInitializer), operationCorrelationTelemetryInitializer.GetType());
}


[Fact]
public static void VerifyDiagnosticListenerNoExceptionWhenAppIdProviderNotFoundFoundInDI()
{
// ARRANGE
var services = ApplicationInsightsExtensionsTests.GetServiceCollectionWithContextAccessor();
var config = new ConfigurationBuilder().AddApplicationInsightsSettings(endpointAddress: "http://localhost:1234/v2/track/").Build();
services.AddApplicationInsightsTelemetry(config);

services.AddSingleton<IApplicationInsightDiagnosticListener, HostingDiagnosticListener>();


IServiceProvider serviceProvider = services.BuildServiceProvider();
var hostingDiagnosticListener = serviceProvider.GetService<IApplicationInsightDiagnosticListener>();

// SHOULD CALL SetAppIdInResponseHeader
Assert.Equal(typeof(HostingDiagnosticListener), hostingDiagnosticListener.GetType());
}

[Fact]
public static void AddsQuickPulseProcessorToTheConfigurationByDefault()
{
Expand Down

0 comments on commit fd1cdc8

Please sign in to comment.