Skip to content

Commit

Permalink
Code review.
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeBlanch committed May 8, 2023
1 parent 79aedbf commit a1d9712
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,27 @@ public void LoggerProviderBuilderAddInstrumentationTest()
[InlineData(false)]
public void LoggerProviderBuilderNestedResolutionUsingBuilderTest(bool callNestedConfigure)
{
bool innerTestExecuted = false;
bool innerConfigureBuilderTestExecuted = false;
bool innerConfigureOpenTelemetryLoggerProviderTestExecuted = false;

using var provider = Sdk.CreateLoggerProviderBuilder()
.ConfigureServices(services =>
{
if (callNestedConfigure)
{
services.ConfigureOpenTelemetryLoggerProvider((sp, builder) => { });
services.ConfigureOpenTelemetryLoggerProvider(
(sp, builder) => innerConfigureOpenTelemetryLoggerProviderTestExecuted = true);
}
})
.ConfigureBuilder((sp, builder) =>
{
innerTestExecuted = true;
innerConfigureBuilderTestExecuted = true;
Assert.Throws<NotSupportedException>(() => sp.GetService<LoggerProvider>());
})
.Build();

Assert.True(innerTestExecuted);
Assert.True(innerConfigureBuilderTestExecuted);
Assert.Equal(callNestedConfigure, innerConfigureOpenTelemetryLoggerProviderTestExecuted);

Assert.Throws<NotSupportedException>(() => provider.GetServiceProvider()?.GetService<LoggerProvider>());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,24 +219,27 @@ public void ConfigureBuilderIConfigurationModifiableTest()
[InlineData(false)]
public void MeterProviderNestedResolutionUsingBuilderTest(bool callNestedConfigure)
{
bool innerTestExecuted = false;
bool innerConfigureBuilderTestExecuted = false;
bool innerConfigureOpenTelemetryLoggerProviderTestExecuted = false;

using var provider = Sdk.CreateMeterProviderBuilder()
.ConfigureServices(services =>
{
if (callNestedConfigure)
{
services.ConfigureOpenTelemetryMeterProvider((sp, builder) => { });
services.ConfigureOpenTelemetryMeterProvider(
(sp, builder) => innerConfigureOpenTelemetryLoggerProviderTestExecuted = true);
}
})
.ConfigureBuilder((sp, builder) =>
{
innerTestExecuted = true;
innerConfigureBuilderTestExecuted = true;
Assert.Throws<NotSupportedException>(() => sp.GetService<MeterProvider>());
})
.Build();

Assert.True(innerTestExecuted);
Assert.True(innerConfigureBuilderTestExecuted);
Assert.Equal(callNestedConfigure, innerConfigureOpenTelemetryLoggerProviderTestExecuted);

Assert.Throws<NotSupportedException>(() => provider.GetServiceProvider()?.GetService<MeterProvider>());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,24 +309,27 @@ public void ConfigureBuilderIConfigurationModifiableTest()
[InlineData(false)]
public void TracerProviderNestedResolutionUsingBuilderTest(bool callNestedConfigure)
{
bool innerTestExecuted = false;
bool innerConfigureBuilderTestExecuted = false;
bool innerConfigureOpenTelemetryLoggerProviderTestExecuted = false;

using var provider = Sdk.CreateTracerProviderBuilder()
.ConfigureServices(services =>
{
if (callNestedConfigure)
{
services.ConfigureOpenTelemetryTracerProvider((sp, builder) => { });
services.ConfigureOpenTelemetryTracerProvider(
(sp, builder) => innerConfigureOpenTelemetryLoggerProviderTestExecuted = true);
}
})
.ConfigureBuilder((sp, builder) =>
{
innerTestExecuted = true;
innerConfigureBuilderTestExecuted = true;
Assert.Throws<NotSupportedException>(() => sp.GetService<TracerProvider>());
})
.Build();

Assert.True(innerTestExecuted);
Assert.True(innerConfigureBuilderTestExecuted);
Assert.Equal(callNestedConfigure, innerConfigureOpenTelemetryLoggerProviderTestExecuted);

Assert.Throws<NotSupportedException>(() => provider.GetServiceProvider()?.GetService<TracerProvider>());
}
Expand Down

0 comments on commit a1d9712

Please sign in to comment.