mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
103c7e7105
* Improve conformance of OpenAI Responses API serving * Update dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Responses/AgentRunResponseExtensions.cs Co-authored-by: Stephen Toub <stoub@microsoft.com> * Update dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/Responses/AgentRunResponseExtensions.cs Co-authored-by: Stephen Toub <stoub@microsoft.com> * Sort packages * Relax adherence where acceptable * nit * PromptCacheKey is not obsolete * format --------- Co-authored-by: Stephen Toub <stoub@microsoft.com>
79 lines
2.2 KiB
C#
79 lines
2.2 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System;
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
namespace Microsoft.Agents.AI.Hosting.OpenAI.UnitTests;
|
|
|
|
/// <summary>
|
|
/// Tests for HostApplicationBuilderExtensions.AddOpenAIResponses method.
|
|
/// </summary>
|
|
public sealed class HostApplicationBuilderExtensionsTests
|
|
{
|
|
/// <summary>
|
|
/// Verifies that AddOpenAIResponses throws ArgumentNullException for null builder.
|
|
/// </summary>
|
|
[Fact]
|
|
public void AddOpenAIResponses_NullBuilder_ThrowsArgumentNullException()
|
|
{
|
|
// Arrange
|
|
IHostApplicationBuilder builder = null!;
|
|
|
|
// Act & Assert
|
|
ArgumentNullException exception = Assert.Throws<ArgumentNullException>(() =>
|
|
builder.AddOpenAIResponses());
|
|
|
|
Assert.Equal("builder", exception.ParamName);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verifies that AddOpenAIResponses returns the same builder instance.
|
|
/// </summary>
|
|
[Fact]
|
|
public void AddOpenAIResponses_ValidBuilder_ReturnsSameBuilder()
|
|
{
|
|
// Arrange
|
|
IHostApplicationBuilder builder = Host.CreateApplicationBuilder();
|
|
|
|
// Act
|
|
IHostApplicationBuilder result = builder.AddOpenAIResponses();
|
|
|
|
// Assert
|
|
Assert.Same(builder, result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verifies that AddOpenAIResponses can be called multiple times without error.
|
|
/// </summary>
|
|
[Fact]
|
|
public void AddOpenAIResponses_MultipleCalls_DoesNotThrow()
|
|
{
|
|
// Arrange
|
|
HostApplicationBuilder builder = Host.CreateApplicationBuilder();
|
|
|
|
// Act
|
|
builder.AddOpenAIResponses();
|
|
builder.AddOpenAIResponses();
|
|
builder.AddOpenAIResponses();
|
|
|
|
// Assert - Building should succeed
|
|
Assert.NotNull(builder.Services);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verifies that AddOpenAIResponses properly configures JSON serialization options.
|
|
/// </summary>
|
|
[Fact]
|
|
public void AddOpenAIResponses_ConfiguresJsonSerialization()
|
|
{
|
|
// Arrange
|
|
HostApplicationBuilder builder = Host.CreateApplicationBuilder();
|
|
|
|
// Act
|
|
builder.AddOpenAIResponses();
|
|
|
|
// Assert - Should add services without error
|
|
Assert.NotNull(builder.Services);
|
|
}
|
|
}
|