@@ -48,8 +48,7 @@ public void UseScopeManager()
4848 ScopeManager . GetCurrent ( ) . Returns ( scopeAndClient ) ;
4949 }
5050
51- public SentryStructuredLogger GetDefaultSut ( ) => new DefaultSentryStructuredLogger ( Hub , ScopeManager , Options , Clock ) ;
52- public SentryStructuredLogger GetDisabledSut ( ) => new DisabledSentryStructuredLogger ( ) ;
51+ public SentryStructuredLogger GetSut ( ) => SentryStructuredLogger . Create ( Hub , ScopeManager , Options , Clock ) ;
5352 }
5453
5554 private readonly Fixture _fixture ;
@@ -64,8 +63,8 @@ public void Create_Enabled_NewDefaultInstance()
6463 {
6564 _fixture . Options . Experimental . EnableLogs = true ;
6665
67- var instance = SentryStructuredLogger . Create ( _fixture . Hub , _fixture . ScopeManager , _fixture . Options , _fixture . Clock ) ;
68- var other = SentryStructuredLogger . Create ( _fixture . Hub , _fixture . ScopeManager , _fixture . Options , _fixture . Clock ) ;
66+ var instance = _fixture . GetSut ( ) ;
67+ var other = _fixture . GetSut ( ) ;
6968
7069 instance . Should ( ) . BeOfType < DefaultSentryStructuredLogger > ( ) ;
7170 instance . Should ( ) . NotBeSameAs ( other ) ;
@@ -76,8 +75,8 @@ public void Create_Disabled_CachedDisabledInstance()
7675 {
7776 _fixture . Options . Experimental . EnableLogs . Should ( ) . BeFalse ( ) ;
7877
79- var instance = SentryStructuredLogger . Create ( _fixture . Hub , _fixture . ScopeManager , _fixture . Options , _fixture . Clock ) ;
80- var other = SentryStructuredLogger . Create ( _fixture . Hub , _fixture . ScopeManager , _fixture . Options , _fixture . Clock ) ;
78+ var instance = _fixture . GetSut ( ) ;
79+ var other = _fixture . GetSut ( ) ;
8180
8281 instance . Should ( ) . BeOfType < DisabledSentryStructuredLogger > ( ) ;
8382 instance . Should ( ) . BeSameAs ( other ) ;
@@ -93,7 +92,7 @@ public void Create_Disabled_CachedDisabledInstance()
9392 public void Log_Enabled_CapturesEnvelope ( SentryLogLevel level )
9493 {
9594 _fixture . Options . Experimental . EnableLogs = true ;
96- var logger = _fixture . GetDefaultSut ( ) ;
95+ var logger = _fixture . GetSut ( ) ;
9796
9897 Envelope envelope = null ! ;
9998 _fixture . Hub . CaptureEnvelope ( Arg . Do < Envelope > ( arg => envelope = arg ) ) ;
@@ -114,7 +113,7 @@ public void Log_Enabled_CapturesEnvelope(SentryLogLevel level)
114113 public void Log_Disabled_DoesNotCaptureEnvelope ( SentryLogLevel level )
115114 {
116115 _fixture . Options . Experimental . EnableLogs . Should ( ) . BeFalse ( ) ;
117- var logger = _fixture . GetDefaultSut ( ) ;
116+ var logger = _fixture . GetSut ( ) ;
118117
119118 logger . Log ( level , "Template string with arguments: {0}, {1}, {2}, {3}" , [ "string" , true , 1 , 2.2 ] , ConfigureLog ) ;
120119
@@ -126,7 +125,7 @@ public void Log_UseScopeManager_CapturesEnvelope()
126125 {
127126 _fixture . UseScopeManager ( ) ;
128127 _fixture . Options . Experimental . EnableLogs = true ;
129- var logger = _fixture . GetDefaultSut ( ) ;
128+ var logger = _fixture . GetSut ( ) ;
130129
131130 Envelope envelope = null ! ;
132131 _fixture . Hub . CaptureEnvelope ( Arg . Do < Envelope > ( arg => envelope = arg ) ) ;
@@ -150,7 +149,7 @@ public void Log_WithBeforeSendLog_InvokesCallback()
150149 configuredLog = log ;
151150 return log ;
152151 } ) ;
153- var logger = _fixture . GetDefaultSut ( ) ;
152+ var logger = _fixture . GetSut ( ) ;
154153
155154 logger . LogTrace ( "Template string with arguments: {0}, {1}, {2}, {3}" , [ "string" , true , 1 , 2.2 ] , ConfigureLog ) ;
156155
@@ -170,7 +169,7 @@ public void Log_WhenBeforeSendLogReturnsNull_DoesNotCaptureEnvelope()
170169 invocations ++ ;
171170 return null ;
172171 } ) ;
173- var logger = _fixture . GetDefaultSut ( ) ;
172+ var logger = _fixture . GetSut ( ) ;
174173
175174 logger . LogTrace ( "Template string with arguments: {0}, {1}, {2}, {3}" , [ "string" , true , 1 , 2.2 ] , ConfigureLog ) ;
176175
@@ -182,7 +181,7 @@ public void Log_WhenBeforeSendLogReturnsNull_DoesNotCaptureEnvelope()
182181 public void Log_InvalidFormat_DoesNotCaptureEnvelope ( )
183182 {
184183 _fixture . Options . Experimental . EnableLogs = true ;
185- var logger = _fixture . GetDefaultSut ( ) ;
184+ var logger = _fixture . GetSut ( ) ;
186185
187186 logger . LogTrace ( "Template string with arguments: {0}, {1}, {2}, {3}, {4}" , [ "string" , true , 1 , 2.2 ] ) ;
188187
@@ -198,9 +197,9 @@ public void Log_InvalidFormat_DoesNotCaptureEnvelope()
198197 public void Log_InvalidConfigureLog_DoesNotCaptureEnvelope ( )
199198 {
200199 _fixture . Options . Experimental . EnableLogs = true ;
201- var logger = _fixture . GetDefaultSut ( ) ;
200+ var logger = _fixture . GetSut ( ) ;
202201
203- logger . LogTrace ( "Template string with arguments: {0}, {1}, {2}, {3}" , [ "string" , true , 1 , 2.2 ] , Throw ) ;
202+ logger . LogTrace ( "Template string with arguments: {0}, {1}, {2}, {3}" , [ "string" , true , 1 , 2.2 ] , static ( SentryLog log ) => throw new InvalidOperationException ( ) ) ;
204203
205204 _fixture . Hub . Received ( 0 ) . CaptureEnvelope ( Arg . Any < Envelope > ( ) ) ;
206205 var entry = _fixture . DiagnosticLogger . Entries . Should ( ) . ContainSingle ( ) . Which ;
@@ -215,7 +214,7 @@ public void Log_InvalidBeforeSendLog_DoesNotCaptureEnvelope()
215214 {
216215 _fixture . Options . Experimental . EnableLogs = true ;
217216 _fixture . Options . Experimental . SetBeforeSendLog ( static ( SentryLog log ) => throw new InvalidOperationException ( ) ) ;
218- var logger = _fixture . GetDefaultSut ( ) ;
217+ var logger = _fixture . GetSut ( ) ;
219218
220219 logger . LogTrace ( "Template string with arguments: {0}, {1}, {2}, {3}" , [ "string" , true , 1 , 2.2 ] ) ;
221220
@@ -231,22 +230,6 @@ private static void ConfigureLog(SentryLog log)
231230 {
232231 log . SetAttribute ( "attribute-key" , "attribute-value" ) ;
233232 }
234-
235- private static void Throw ( SentryLog log )
236- {
237- throw new InvalidOperationException ( ) ;
238- }
239-
240- [ Fact ]
241- public void CreateDisabled_EvenWhenEnabled_DoesNotCaptureEnvelope ( )
242- {
243- _fixture . Options . Experimental . EnableLogs = true ;
244- var logger = _fixture . GetDisabledSut ( ) ;
245-
246- logger . LogTrace ( "Template string with arguments: {0}, {1}, {2}, {3}" , [ "string" , true , 1 , 2.2 ] , ConfigureLog ) ;
247-
248- _fixture . Hub . Received ( 0 ) . CaptureEnvelope ( Arg . Any < Envelope > ( ) ) ;
249- }
250233}
251234
252235file static class AssertionExtensions
0 commit comments