db620d33df
dotnet-build-and-test / dotnet-test-functions (push) Has been cancelled
dotnet-build-and-test / paths-filter (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Debug, windows-latest, net9.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net8.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-foundry-hosted-it (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test-check (push) Has been cancelled
dotnet-build-and-test / Integration Test Report (push) Has been cancelled
CodeQL / Analyze (csharp) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
76 lines
2.1 KiB
C#
76 lines
2.1 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System;
|
|
using System.Text.Json;
|
|
using Moq;
|
|
|
|
namespace Microsoft.Agents.AI.UnitTests;
|
|
|
|
/// <summary>
|
|
/// Unit tests for the <see cref="ToolApprovalAgentBuilderExtensions"/> class.
|
|
/// </summary>
|
|
public class ToolApprovalAgentBuilderExtensionsTests
|
|
{
|
|
/// <summary>
|
|
/// Verify that UseToolApproval throws ArgumentNullException when builder is null.
|
|
/// </summary>
|
|
[Fact]
|
|
public void UseToolApproval_WithNullBuilder_ThrowsArgumentNullException()
|
|
{
|
|
// Act & Assert
|
|
Assert.Throws<ArgumentNullException>("builder", () => ((AIAgentBuilder)null!).UseToolApproval());
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verify that UseToolApproval returns a ToolApprovalAgent.
|
|
/// </summary>
|
|
[Fact]
|
|
public void UseToolApproval_WithValidBuilder_ReturnsToolApprovalAgent()
|
|
{
|
|
// Arrange
|
|
var mockAgent = new Mock<AIAgent>();
|
|
var builder = new AIAgentBuilder(mockAgent.Object);
|
|
|
|
// Act
|
|
var result = builder.UseToolApproval().Build();
|
|
|
|
// Assert
|
|
Assert.IsType<ToolApprovalAgent>(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verify that UseToolApproval returns the same builder instance for chaining.
|
|
/// </summary>
|
|
[Fact]
|
|
public void UseToolApproval_ReturnsBuilderForChaining()
|
|
{
|
|
// Arrange
|
|
var mockAgent = new Mock<AIAgent>();
|
|
var builder = new AIAgentBuilder(mockAgent.Object);
|
|
|
|
// Act
|
|
var result = builder.UseToolApproval();
|
|
|
|
// Assert
|
|
Assert.Same(builder, result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verify that UseToolApproval with custom JsonSerializerOptions works correctly.
|
|
/// </summary>
|
|
[Fact]
|
|
public void UseToolApproval_WithCustomOptions_ReturnsToolApprovalAgent()
|
|
{
|
|
// Arrange
|
|
var mockAgent = new Mock<AIAgent>();
|
|
var builder = new AIAgentBuilder(mockAgent.Object);
|
|
var options = new ToolApprovalAgentOptions { JsonSerializerOptions = new JsonSerializerOptions() };
|
|
|
|
// Act
|
|
var result = builder.UseToolApproval(options: options).Build();
|
|
|
|
// Assert
|
|
Assert.IsType<ToolApprovalAgent>(result);
|
|
}
|
|
}
|