mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
ab3d898979
* Add unit tests for create conversation executor * Update indentation and comment typo. * Added unit tests for declarative executor SetMultipleVariablesExecutor * Updated comments and syntactic sugar * Add unit test for declarative executor RetrieveConversationMessageExecutor * Removed irrelevant code statements * Updated based on copilot feedback.
50 lines
1.5 KiB
C#
50 lines
1.5 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.Extensions.AI;
|
|
using Moq;
|
|
|
|
namespace Microsoft.Agents.AI.Workflows.Declarative.UnitTests;
|
|
|
|
/// <summary>
|
|
/// Mock implementation of <see cref="WorkflowAgentProvider"/> for unit testing purposes.
|
|
/// </summary>
|
|
internal sealed class MockAgentProvider : Mock<WorkflowAgentProvider>
|
|
{
|
|
public IList<string> ExistingConversationIds { get; } = [];
|
|
|
|
public ChatMessage? TestChatMessage { get; set; }
|
|
|
|
public MockAgentProvider()
|
|
{
|
|
this.Setup(provider => provider.CreateConversationAsync(It.IsAny<CancellationToken>()))
|
|
.Returns(() => Task.FromResult(this.CreateConversationId()));
|
|
|
|
this.Setup(provider => provider.GetMessageAsync(
|
|
It.IsAny<string>(),
|
|
It.IsAny<string>(),
|
|
It.IsAny<CancellationToken>()))
|
|
.Returns(Task.FromResult(this.CreateChatMessage()));
|
|
}
|
|
|
|
private string CreateConversationId()
|
|
{
|
|
string newConversationId = Guid.NewGuid().ToString("N");
|
|
this.ExistingConversationIds.Add(newConversationId);
|
|
|
|
return newConversationId;
|
|
}
|
|
|
|
private ChatMessage CreateChatMessage()
|
|
{
|
|
this.TestChatMessage = new ChatMessage(ChatRole.User, Guid.NewGuid().ToString("N"))
|
|
{
|
|
MessageId = Guid.NewGuid().ToString("N"),
|
|
};
|
|
return this.TestChatMessage;
|
|
}
|
|
}
|