@@ -82,7 +82,7 @@ public void CheckStateForUnstructuredLog(bool includeFormattedMessage)
82
82
const string message = "Hello, World!" ;
83
83
logger . LogInformation ( message ) ;
84
84
85
- Assert . Null ( exportedItems [ 0 ] . State ) ;
85
+ Assert . NotNull ( exportedItems [ 0 ] . State ) ;
86
86
87
87
var attributes = exportedItems [ 0 ] . Attributes ;
88
88
Assert . NotNull ( attributes ) ;
@@ -113,7 +113,7 @@ public void CheckStateForUnstructuredLogWithStringInterpolation(bool includeForm
113
113
var message = $ "Hello from potato { 0.99 } .";
114
114
logger . LogInformation ( message ) ;
115
115
116
- Assert . Null ( exportedItems [ 0 ] . State ) ;
116
+ Assert . NotNull ( exportedItems [ 0 ] . State ) ;
117
117
118
118
var attributes = exportedItems [ 0 ] . Attributes ;
119
119
Assert . NotNull ( attributes ) ;
@@ -143,7 +143,7 @@ public void CheckStateForStructuredLogWithTemplate(bool includeFormattedMessage)
143
143
const string message = "Hello from {name} {price}." ;
144
144
logger . LogInformation ( message , "tomato" , 2.99 ) ;
145
145
146
- Assert . Null ( exportedItems [ 0 ] . State ) ;
146
+ Assert . NotNull ( exportedItems [ 0 ] . State ) ;
147
147
148
148
var attributes = exportedItems [ 0 ] . Attributes ;
149
149
Assert . NotNull ( attributes ) ;
@@ -185,7 +185,7 @@ public void CheckStateForStructuredLogWithStrongType(bool includeFormattedMessag
185
185
var food = new Food { Name = "artichoke" , Price = 3.99 } ;
186
186
logger . LogInformation ( "{food}" , food ) ;
187
187
188
- Assert . Null ( exportedItems [ 0 ] . State ) ;
188
+ Assert . NotNull ( exportedItems [ 0 ] . State ) ;
189
189
190
190
var attributes = exportedItems [ 0 ] . Attributes ;
191
191
Assert . NotNull ( attributes ) ;
@@ -226,7 +226,7 @@ public void CheckStateForStructuredLogWithAnonymousType(bool includeFormattedMes
226
226
var anonymousType = new { Name = "pumpkin" , Price = 5.99 } ;
227
227
logger . LogInformation ( "{food}" , anonymousType ) ;
228
228
229
- Assert . Null ( exportedItems [ 0 ] . State ) ;
229
+ Assert . NotNull ( exportedItems [ 0 ] . State ) ;
230
230
231
231
var attributes = exportedItems [ 0 ] . Attributes ;
232
232
Assert . NotNull ( attributes ) ;
@@ -271,7 +271,7 @@ public void CheckStateForStructuredLogWithGeneralType(bool includeFormattedMessa
271
271
} ;
272
272
logger . LogInformation ( "{food}" , food ) ;
273
273
274
- Assert . Null ( exportedItems [ 0 ] . State ) ;
274
+ Assert . NotNull ( exportedItems [ 0 ] . State ) ;
275
275
276
276
var attributes = exportedItems [ 0 ] . Attributes ;
277
277
Assert . NotNull ( attributes ) ;
@@ -321,7 +321,13 @@ public void CheckStateForExceptionLogged()
321
321
const string message = "Exception Occurred" ;
322
322
logger . LogInformation ( exception , message ) ;
323
323
324
- Assert . Null ( exportedItems [ 0 ] . State ) ;
324
+ Assert . NotNull ( exportedItems [ 0 ] . State ) ;
325
+
326
+ var state = exportedItems [ 0 ] . State ;
327
+ var itemCount = state . GetType ( ) . GetProperty ( "Count" ) . GetValue ( state ) ;
328
+
329
+ // state only has {OriginalFormat}
330
+ Assert . Equal ( 1 , itemCount ) ;
325
331
326
332
var attributes = exportedItems [ 0 ] . Attributes ;
327
333
Assert . NotNull ( attributes ) ;
@@ -334,6 +340,7 @@ public void CheckStateForExceptionLogged()
334
340
Assert . Equal ( exceptionMessage , loggedException . Message ) ;
335
341
336
342
Assert . Equal ( message , exportedItems [ 0 ] . Body ) ;
343
+ Assert . Equal ( message , state . ToString ( ) ) ;
337
344
Assert . Null ( exportedItems [ 0 ] . FormattedMessage ) ;
338
345
}
339
346
@@ -711,7 +718,14 @@ public void VerifyParseStateValues_UsingStandardExtensions(bool parseStateValues
711
718
var logRecord = exportedItems [ 0 ] ;
712
719
713
720
Assert . NotNull ( logRecord . StateValues ) ;
714
- Assert . Null ( logRecord . State ) ;
721
+ if ( parseStateValues )
722
+ {
723
+ Assert . Null ( logRecord . State ) ;
724
+ }
725
+ else
726
+ {
727
+ Assert . NotNull ( logRecord . State ) ;
728
+ }
715
729
716
730
Assert . NotNull ( logRecord . StateValues ) ;
717
731
Assert . Equal ( 3 , logRecord . StateValues . Count ) ;
@@ -725,7 +739,14 @@ public void VerifyParseStateValues_UsingStandardExtensions(bool parseStateValues
725
739
logRecord = exportedItems [ 1 ] ;
726
740
727
741
Assert . NotNull ( logRecord . StateValues ) ;
728
- Assert . Null ( logRecord . State ) ;
742
+ if ( parseStateValues )
743
+ {
744
+ Assert . Null ( logRecord . State ) ;
745
+ }
746
+ else
747
+ {
748
+ Assert . NotNull ( logRecord . State ) ;
749
+ }
729
750
730
751
Assert . NotNull ( logRecord . StateValues ) ;
731
752
Assert . Equal ( 4 , logRecord . StateValues . Count ) ;
0 commit comments