@@ -37,8 +37,8 @@ public class ChatTelemetryTests
3737 public void AllTelemetryOff ( )
3838 {
3939 var telemetry = new OpenTelemetrySource ( RequestModel , new Uri ( Endpoint ) ) ;
40- Assert . IsNull ( telemetry . StartChatScope ( new ChatCompletionOptions ( ) ) ) ;
41- Assert . IsNull ( Activity . Current ) ;
40+ Assert . That ( telemetry . StartChatScope ( new ChatCompletionOptions ( ) ) , Is . Null ) ;
41+ Assert . That ( Activity . Current , Is . Null ) ;
4242 }
4343
4444 [ Test ]
@@ -47,8 +47,8 @@ public void SwitchOffAllTelemetryOn()
4747 using var activityListener = new TestActivityListener ( "OpenAI.ChatClient" ) ;
4848 using var meterListener = new TestMeterListener ( "OpenAI.ChatClient" ) ;
4949 var telemetry = new OpenTelemetrySource ( RequestModel , new Uri ( Endpoint ) ) ;
50- Assert . IsNull ( telemetry . StartChatScope ( new ChatCompletionOptions ( ) ) ) ;
51- Assert . IsNull ( Activity . Current ) ;
50+ Assert . That ( telemetry . StartChatScope ( new ChatCompletionOptions ( ) ) , Is . Null ) ;
51+ Assert . That ( Activity . Current , Is . Null ) ;
5252 }
5353
5454 [ Test ]
@@ -64,8 +64,8 @@ public void MetricsOnTracingOff()
6464 using var scope = telemetry . StartChatScope ( new ChatCompletionOptions ( ) ) ;
6565 var elapsedMin = Stopwatch . StartNew ( ) ;
6666
67- Assert . Null ( Activity . Current ) ;
68- Assert . NotNull ( scope ) ;
67+ Assert . That ( Activity . Current , Is . Null ) ;
68+ Assert . That ( scope , Is . Not . Null ) ;
6969
7070 // so we have some duration to measure
7171 Thread . Sleep ( 20 ) ;
@@ -94,7 +94,7 @@ public void MetricsOnTracingOffException()
9494 }
9595
9696 ValidateDuration ( meterListener , null , TimeSpan . MinValue , TimeSpan . MaxValue ) ;
97- Assert . IsNull ( meterListener . GetMeasurements ( "gen_ai.client.token.usage" ) ) ;
97+ Assert . That ( meterListener . GetMeasurements ( "gen_ai.client.token.usage" ) , Is . Null ) ;
9898 }
9999
100100 [ Test ]
@@ -111,16 +111,16 @@ public void TracingOnMetricsOff()
111111 using ( var scope = telemetry . StartChatScope ( new ChatCompletionOptions ( ) ) )
112112 {
113113 activity = Activity . Current ;
114- Assert . IsNull ( activity . GetTagItem ( "gen_ai.request.temperature" ) ) ;
115- Assert . IsNull ( activity . GetTagItem ( "gen_ai.request.top_p" ) ) ;
116- Assert . IsNull ( activity . GetTagItem ( "gen_ai.request.max_tokens" ) ) ;
114+ Assert . That ( activity . GetTagItem ( "gen_ai.request.temperature" ) , Is . Null ) ;
115+ Assert . That ( activity . GetTagItem ( "gen_ai.request.top_p" ) , Is . Null ) ;
116+ Assert . That ( activity . GetTagItem ( "gen_ai.request.max_tokens" ) , Is . Null ) ;
117117
118- Assert . NotNull ( scope ) ;
118+ Assert . That ( scope , Is . Not . Null ) ;
119119
120120 scope . RecordChatCompletion ( chatCompletion ) ;
121121 }
122122
123- Assert . Null ( Activity . Current ) ;
123+ Assert . That ( Activity . Current , Is . Null ) ;
124124 Assert . That ( listener . Activities . Count , Is . EqualTo ( 1 ) ) ;
125125
126126 ValidateChatActivity ( listener . Activities . Single ( ) , chatCompletion , RequestModel , Host , Port ) ;
@@ -149,7 +149,7 @@ public void ChatTracingAllAttributes()
149149 Assert . That ( Activity . Current . GetTagItem ( "gen_ai.request.max_tokens" ) , Is . EqualTo ( options . MaxOutputTokenCount . Value ) ) ;
150150 scope . RecordChatCompletion ( chatCompletion ) ;
151151 }
152- Assert . Null ( Activity . Current ) ;
152+ Assert . That ( Activity . Current , Is . Null ) ;
153153
154154 ValidateChatActivity ( listener . Activities . Single ( ) , chatCompletion , RequestModel , Host , Port ) ;
155155 }
@@ -168,7 +168,7 @@ public void ChatTracingException()
168168 scope . RecordException ( error ) ;
169169 }
170170
171- Assert . Null ( Activity . Current ) ;
171+ Assert . That ( Activity . Current , Is . Null ) ;
172172
173173 ValidateChatActivity ( listener . Activities . Single ( ) , error , RequestModel , Host , Port ) ;
174174 }
@@ -224,7 +224,7 @@ public async Task ChatTracingAndMetricsMultiple()
224224 var usages = meterListener . GetMeasurements ( "gen_ai.client.token.usage" ) ;
225225 // we don't report usage if there was no response
226226 Assert . That ( usages . Count , Is . EqualTo ( numberOfSuccessfulResponses * 2 ) ) ;
227- Assert . IsEmpty ( usages . Where ( u => u . tags . ContainsKey ( "error.type" ) ) ) ;
227+ Assert . That ( usages . Where ( u => u . tags . ContainsKey ( "error.type" ) ) , Is . Empty ) ;
228228
229229 Assert . That ( usages
230230 . Where ( u => u . tags . Contains ( new KeyValuePair < string , object > ( "gen_ai.token.type" , "input" ) ) )
@@ -243,39 +243,39 @@ private void SetMessages(ChatCompletionOptions options, params ChatMessage[] mes
243243 private void ValidateDuration ( TestMeterListener listener , ChatCompletion response , TimeSpan durationMin , TimeSpan durationMax )
244244 {
245245 var duration = listener . GetInstrument ( "gen_ai.client.operation.duration" ) ;
246- Assert . IsNotNull ( duration ) ;
247- Assert . IsInstanceOf < Histogram < double > > ( duration ) ;
246+ Assert . That ( duration , Is . Not . Null ) ;
247+ Assert . That ( duration , Is . InstanceOf < Histogram < double > > ( ) ) ;
248248
249249 var measurements = listener . GetMeasurements ( "gen_ai.client.operation.duration" ) ;
250- Assert . IsNotNull ( measurements ) ;
250+ Assert . That ( measurements , Is . Not . Null ) ;
251251 Assert . That ( measurements . Count , Is . EqualTo ( 1 ) ) ;
252252
253253 var measurement = measurements [ 0 ] ;
254- Assert . IsInstanceOf < double > ( measurement . value ) ;
255- Assert . GreaterOrEqual ( ( double ) measurement . value , durationMin . TotalSeconds ) ;
256- Assert . LessOrEqual ( ( double ) measurement . value , durationMax . TotalSeconds ) ;
254+ Assert . That ( measurement . value , Is . InstanceOf < double > ( ) ) ;
255+ Assert . That ( ( double ) measurement . value , Is . GreaterThanOrEqualTo ( durationMin . TotalSeconds ) ) ;
256+ Assert . That ( ( double ) measurement . value , Is . LessThanOrEqualTo ( durationMax . TotalSeconds ) ) ;
257257
258258 ValidateChatMetricTags ( measurement , response , RequestModel , Host , Port ) ;
259259 }
260260
261261 private void ValidateUsage ( TestMeterListener listener , ChatCompletion response , int inputTokens , int outputTokens )
262262 {
263263 var usage = listener . GetInstrument ( "gen_ai.client.token.usage" ) ;
264- Assert . IsNotNull ( usage ) ;
265- Assert . IsInstanceOf < Histogram < long > > ( usage ) ;
264+ Assert . That ( usage , Is . Not . Null ) ;
265+ Assert . That ( usage , Is . InstanceOf < Histogram < long > > ( ) ) ;
266266
267267 var measurements = listener . GetMeasurements ( "gen_ai.client.token.usage" ) ;
268- Assert . IsNotNull ( measurements ) ;
268+ Assert . That ( measurements , Is . Not . Null ) ;
269269 Assert . That ( measurements . Count , Is . EqualTo ( 2 ) ) ;
270270
271271 foreach ( var measurement in measurements )
272272 {
273- Assert . IsInstanceOf < long > ( measurement . value ) ;
273+ Assert . That ( measurement . value , Is . InstanceOf < long > ( ) ) ;
274274 ValidateChatMetricTags ( measurement , response , RequestModel , Host , Port ) ;
275275 }
276276
277- Assert . True ( measurements [ 0 ] . tags . TryGetValue ( "gen_ai.token.type" , out var type ) ) ;
278- Assert . IsInstanceOf < string > ( type ) ;
277+ Assert . That ( measurements [ 0 ] . tags . TryGetValue ( "gen_ai.token.type" , out var type ) ) ;
278+ Assert . That ( type , Is . InstanceOf < string > ( ) ) ;
279279
280280 TestMeasurement input = ( type is "input" ) ? measurements [ 0 ] : measurements [ 1 ] ;
281281 TestMeasurement output = ( type is "input" ) ? measurements [ 1 ] : measurements [ 0 ] ;
0 commit comments