File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
test/Polly.Extensions.Tests/Issues Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ using Microsoft . Extensions . DependencyInjection ;
2
+ using Microsoft . Extensions . DependencyInjection . Extensions ;
3
+ using Microsoft . Extensions . Logging ;
4
+ using Polly . Registry ;
5
+
6
+ namespace Polly . Extensions . Tests . Issues ;
7
+
8
+ public partial class IssuesTests
9
+ {
10
+ [ Fact ]
11
+ public void OverrideLoggerFactory_ByExplicitConfigureTelemetryCall_1783 ( )
12
+ {
13
+ // Arrange
14
+ using var loggerFactory1 = new FakeLoggerFactory ( ) ;
15
+ using var loggerFactory2 = new FakeLoggerFactory ( ) ;
16
+ var services = new ServiceCollection ( ) ;
17
+ services . TryAddSingleton < ILoggerFactory > ( loggerFactory1 ) ;
18
+
19
+ // Act
20
+ services . AddResiliencePipeline ( "dummy" , builder =>
21
+ {
22
+ builder . AddTimeout ( TimeSpan . FromSeconds ( 1 ) ) ;
23
+
24
+ // This call should override the base factory
25
+ builder . ConfigureTelemetry ( loggerFactory2 ) ;
26
+ } ) ;
27
+
28
+ // Assert
29
+ var provider = services . BuildServiceProvider ( ) . GetRequiredService < ResiliencePipelineProvider < string > > ( ) ;
30
+
31
+ provider . GetPipeline ( "dummy" ) . Execute ( ( ) => { } ) ;
32
+
33
+ loggerFactory1 . FakeLogger . GetRecords ( ) . Should ( ) . BeEmpty ( ) ;
34
+ loggerFactory2 . FakeLogger . GetRecords ( ) . Should ( ) . NotBeEmpty ( ) ;
35
+ }
36
+ }
You can’t perform that action at this time.
0 commit comments