-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test that verifies overriding by using
ConfigureTelemetry
(#1787)
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
test/Polly.Extensions.Tests/Issues/IssuesTests.OverrideLoggerFactory_1783.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.DependencyInjection.Extensions; | ||
using Microsoft.Extensions.Logging; | ||
using Polly.Registry; | ||
|
||
namespace Polly.Extensions.Tests.Issues; | ||
|
||
public partial class IssuesTests | ||
{ | ||
[Fact] | ||
public void OverrideLoggerFactory_ByExplicitConfigureTelemetryCall_1783() | ||
{ | ||
// Arrange | ||
using var loggerFactory1 = new FakeLoggerFactory(); | ||
using var loggerFactory2 = new FakeLoggerFactory(); | ||
var services = new ServiceCollection(); | ||
services.TryAddSingleton<ILoggerFactory>(loggerFactory1); | ||
|
||
// Act | ||
services.AddResiliencePipeline("dummy", builder => | ||
{ | ||
builder.AddTimeout(TimeSpan.FromSeconds(1)); | ||
|
||
// This call should override the base factory | ||
builder.ConfigureTelemetry(loggerFactory2); | ||
}); | ||
|
||
// Assert | ||
var provider = services.BuildServiceProvider().GetRequiredService<ResiliencePipelineProvider<string>>(); | ||
|
||
provider.GetPipeline("dummy").Execute(() => { }); | ||
|
||
loggerFactory1.FakeLogger.GetRecords().Should().BeEmpty(); | ||
loggerFactory2.FakeLogger.GetRecords().Should().NotBeEmpty(); | ||
} | ||
} |