mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
92925a8bc7
* Draft * Nullable init * Complete * Consistency * Test fix * Typo * Comment * Updated * Fix identifier * Test fix * Comment typo * Better naming * Comment * Tweak comment
49 lines
1.7 KiB
C#
49 lines
1.7 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System.Collections.Generic;
|
|
using Microsoft.Agents.AI.Workflows.Declarative.Events;
|
|
using Microsoft.Extensions.AI;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Microsoft.Agents.AI.Workflows.Declarative.UnitTests.Events;
|
|
|
|
/// <summary>
|
|
/// Verify <see cref="AgentFunctionToolRequest"/> class
|
|
/// </summary>
|
|
public sealed class AgentFunctionToolRequestTest(ITestOutputHelper output) : EventTest(output)
|
|
{
|
|
[Fact]
|
|
public void VerifySerializationEmpty()
|
|
{
|
|
// Arrange & Act
|
|
AgentFunctionToolRequest copy = VerifyEventSerialization(new AgentFunctionToolRequest("testagent", []));
|
|
|
|
// Assert
|
|
Assert.Equal("testagent", copy.AgentName);
|
|
Assert.Empty(copy.FunctionCalls);
|
|
}
|
|
|
|
[Fact]
|
|
public void VerifySerializationWithRequests()
|
|
{
|
|
// Arrange & Act
|
|
AgentFunctionToolRequest copy =
|
|
VerifyEventSerialization(
|
|
new AgentFunctionToolRequest(
|
|
"agent",
|
|
[
|
|
new FunctionCallContent("call1", "result1"),
|
|
new FunctionCallContent("call2", "result2", new Dictionary<string, object?>() { { "name", "Clam Chowder" } }),
|
|
]));
|
|
|
|
// Assert
|
|
Assert.Equal("agent", copy.AgentName);
|
|
Assert.Equal(2, copy.FunctionCalls.Count);
|
|
Assert.IsType<FunctionCallContent>(copy.FunctionCalls[0]);
|
|
Assert.Null(copy.FunctionCalls[0].Arguments);
|
|
Assert.IsType<FunctionCallContent>(copy.FunctionCalls[1]);
|
|
Assert.NotNull(copy.FunctionCalls[1].Arguments);
|
|
Assert.NotEmpty(copy.FunctionCalls[1].Arguments!);
|
|
}
|
|
}
|