Skip to content

Commit

Permalink
Fixed unit test failure from shared reference. (#308)
Browse files Browse the repository at this point in the history
* Fixed unit test failure from shared reference.
  • Loading branch information
dnduffy authored Jan 5, 2017
1 parent 20d3166 commit 0d8ab7f
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,21 @@ public static void RegistersTelemetryClientToGetTelemetryConfigurationFromContai
IServiceProvider serviceProvider = services.BuildServiceProvider();
var configuration = serviceProvider.GetTelemetryConfiguration();
configuration.InstrumentationKey = Guid.NewGuid().ToString();
configuration.TelemetryChannel = telemetryChannel;
ITelemetryChannel oldChannel = configuration.TelemetryChannel;
try
{
configuration.TelemetryChannel = telemetryChannel;

var telemetryClient = serviceProvider.GetRequiredService<TelemetryClient>();
telemetryClient.TrackEvent("myevent");
var telemetryClient = serviceProvider.GetRequiredService<TelemetryClient>();
telemetryClient.TrackEvent("myevent");

// We want to check that configuration from contaier was used but configuration is a private field so we check
// instrumentation key instead
Assert.Equal(configuration.InstrumentationKey, sentTelemetry.Context.InstrumentationKey);
// We want to check that configuration from container was used but configuration is a private field so we check instrumentation key instead.
Assert.Equal(configuration.InstrumentationKey, sentTelemetry.Context.InstrumentationKey);
}
finally
{
configuration.TelemetryChannel = oldChannel;
}
}

[Fact]
Expand Down

0 comments on commit 0d8ab7f

Please sign in to comment.