Files
agent-framework/dotnet/tests/Microsoft.Extensions.AI.Agents.Hosting.UnitTests/AgentActorTests.cs
T
Reuben Bond e7441ee29e .NET: Add agent hosting package and update sample (#296)
* Add agent hosting package and update sample

* Review feedback and cleanup

* Include the narrator

* wip

* wip

* Remove workaround for empty state writes.

* Handle changes to AgentThread.

* One more.

* Fix.

---------

Co-authored-by: Aditya Mandaleeka <adityam@microsoft.com>
2025-08-06 21:26:36 +00:00

36 lines
1.1 KiB
C#

// Copyright (c) Microsoft. All rights reserved.
using System.Threading.Tasks;
using Microsoft.Extensions.AI.Agents.Runtime;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Moq;
namespace Microsoft.Extensions.AI.Agents.Hosting.UnitTests;
/// <summary>
/// Unit tests for <see cref="AgentActor"/>.
/// </summary>
public class AgentActorTests
{
/// <summary>
/// Verifies that calling DisposeAsync completes successfully without throwing an exception.
/// </summary>
[Fact]
public async Task DisposeAsync_NoException_CompletesSuccessfullyAsync()
{
// Arrange
var mockAgent = new Mock<AIAgent>();
var mockContext = new Mock<IActorRuntimeContext>();
var mockLogger = NullLoggerFactory.Instance.CreateLogger<AgentActor>();
var actor = new AgentActor(mockAgent.Object, mockContext.Object, mockLogger);
// Act
var valueTask = actor.DisposeAsync();
// Assert
Assert.True(valueTask.IsCompleted, "DisposeAsync should return a completed ValueTask.");
await valueTask;
}
}