@@ -291,6 +291,85 @@ public void AsIChatClientWithStoredOutputDisabled_InnerResponsesClientIsAccessib
291291 Assert . Same ( responseClient , innerClient ) ;
292292 }
293293
294+ /// <summary>
295+ /// Verify that AsIChatClientWithStoredOutputDisabled with includeReasoningEncryptedContent false
296+ /// wraps the original ResponsesClient, which remains accessible via the service chain.
297+ /// </summary>
298+ [ Fact ]
299+ public void AsIChatClientWithStoredOutputDisabled_WithIncludeReasoningFalse_InnerResponsesClientIsAccessible ( )
300+ {
301+ // Arrange
302+ var responseClient = new TestOpenAIResponseClient ( ) ;
303+
304+ // Act
305+ var chatClient = responseClient . AsIChatClientWithStoredOutputDisabled ( includeReasoningEncryptedContent : false ) ;
306+
307+ // Assert - the inner ResponsesClient should be accessible via GetService
308+ var innerClient = chatClient . GetService < ResponsesClient > ( ) ;
309+ Assert . NotNull ( innerClient ) ;
310+ Assert . Same ( responseClient , innerClient ) ;
311+ }
312+
313+ /// <summary>
314+ /// Verify that AsIChatClientWithStoredOutputDisabled with default parameter (includeReasoningEncryptedContent = true)
315+ /// configures StoredOutputEnabled to false and includes ReasoningEncryptedContent in IncludedProperties.
316+ /// </summary>
317+ [ Fact ]
318+ public void AsIChatClientWithStoredOutputDisabled_Default_ConfiguresStoredOutputDisabledWithReasoningEncryptedContent ( )
319+ {
320+ // Arrange
321+ var responseClient = new TestOpenAIResponseClient ( ) ;
322+
323+ // Act
324+ var chatClient = responseClient . AsIChatClientWithStoredOutputDisabled ( ) ;
325+
326+ // Assert
327+ var createResponseOptions = GetCreateResponseOptionsFromPipeline ( chatClient ) ;
328+ Assert . NotNull ( createResponseOptions ) ;
329+ Assert . False ( createResponseOptions . StoredOutputEnabled ) ;
330+ Assert . Contains ( IncludedResponseProperty . ReasoningEncryptedContent , createResponseOptions . IncludedProperties ) ;
331+ }
332+
333+ /// <summary>
334+ /// Verify that AsIChatClientWithStoredOutputDisabled with includeReasoningEncryptedContent explicitly set to true
335+ /// configures StoredOutputEnabled to false and includes ReasoningEncryptedContent in IncludedProperties.
336+ /// </summary>
337+ [ Fact ]
338+ public void AsIChatClientWithStoredOutputDisabled_WithIncludeReasoningTrue_ConfiguresStoredOutputDisabledWithReasoningEncryptedContent ( )
339+ {
340+ // Arrange
341+ var responseClient = new TestOpenAIResponseClient ( ) ;
342+
343+ // Act
344+ var chatClient = responseClient . AsIChatClientWithStoredOutputDisabled ( includeReasoningEncryptedContent : true ) ;
345+
346+ // Assert
347+ var createResponseOptions = GetCreateResponseOptionsFromPipeline ( chatClient ) ;
348+ Assert . NotNull ( createResponseOptions ) ;
349+ Assert . False ( createResponseOptions . StoredOutputEnabled ) ;
350+ Assert . Contains ( IncludedResponseProperty . ReasoningEncryptedContent , createResponseOptions . IncludedProperties ) ;
351+ }
352+
353+ /// <summary>
354+ /// Verify that AsIChatClientWithStoredOutputDisabled with includeReasoningEncryptedContent set to false
355+ /// configures StoredOutputEnabled to false and does not include ReasoningEncryptedContent in IncludedProperties.
356+ /// </summary>
357+ [ Fact ]
358+ public void AsIChatClientWithStoredOutputDisabled_WithIncludeReasoningFalse_ConfiguresStoredOutputDisabledWithoutReasoningEncryptedContent ( )
359+ {
360+ // Arrange
361+ var responseClient = new TestOpenAIResponseClient ( ) ;
362+
363+ // Act
364+ var chatClient = responseClient . AsIChatClientWithStoredOutputDisabled ( includeReasoningEncryptedContent : false ) ;
365+
366+ // Assert
367+ var createResponseOptions = GetCreateResponseOptionsFromPipeline ( chatClient ) ;
368+ Assert . NotNull ( createResponseOptions ) ;
369+ Assert . False ( createResponseOptions . StoredOutputEnabled ) ;
370+ Assert . DoesNotContain ( IncludedResponseProperty . ReasoningEncryptedContent , createResponseOptions . IncludedProperties ) ;
371+ }
372+
294373 /// <summary>
295374 /// A simple test IServiceProvider implementation for testing.
296375 /// </summary>
@@ -309,4 +388,24 @@ private sealed class TestServiceProvider : IServiceProvider
309388 BindingFlags . Instance | BindingFlags . Public | BindingFlags . NonPublic ) ;
310389 return property ? . GetValue ( client ) as IServiceProvider ;
311390 }
391+
392+ /// <summary>
393+ /// Extracts the <see cref="CreateResponseOptions"/> produced by the ConfigureOptions pipeline
394+ /// by using reflection to access the configure action and invoking it on a test <see cref="ChatOptions"/>.
395+ /// </summary>
396+ private static CreateResponseOptions ? GetCreateResponseOptionsFromPipeline ( IChatClient chatClient )
397+ {
398+ // The ConfigureOptionsChatClient stores the configure action in a private field.
399+ var configureField = chatClient . GetType ( ) . GetField ( "_configureOptions" , BindingFlags . NonPublic | BindingFlags . Instance ) ;
400+ Assert . NotNull ( configureField ) ;
401+
402+ var configureAction = configureField . GetValue ( chatClient ) as Action < ChatOptions > ;
403+ Assert . NotNull ( configureAction ) ;
404+
405+ var options = new ChatOptions ( ) ;
406+ configureAction ( options ) ;
407+
408+ Assert . NotNull ( options . RawRepresentationFactory ) ;
409+ return options . RawRepresentationFactory ( chatClient ) as CreateResponseOptions ;
410+ }
312411}
0 commit comments