mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
75a8335af5
* Builds locally and tests pass * Fix typo * Reverted nuget config change to remove internal feed and map to new public object model package with renames. * Renaming Bot object model in additional sample. --------- Co-authored-by: Peter Ibekwe <peibekwe@microsoft.com>
70 lines
2.3 KiB
C#
70 lines
2.3 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.Agents.AI.Workflows.Declarative.Extensions;
|
|
using Microsoft.Agents.AI.Workflows.Declarative.ObjectModel;
|
|
using Microsoft.Agents.ObjectModel;
|
|
using Microsoft.Extensions.AI;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Microsoft.Agents.AI.Workflows.Declarative.UnitTests.ObjectModel;
|
|
|
|
/// <summary>
|
|
/// Tests for <see cref="RetrieveConversationMessageExecutor"/>.
|
|
/// </summary>
|
|
public sealed class RetrieveConversationMessageExecutorTest(ITestOutputHelper output) : WorkflowActionExecutorTest(output)
|
|
{
|
|
[Fact]
|
|
public async Task RetrieveMessageSuccessfullyAsync()
|
|
{
|
|
// Arrange, Act, Assert
|
|
await this.ExecuteTestAsync(nameof(RetrieveMessageSuccessfullyAsync),
|
|
"TestMessage");
|
|
}
|
|
|
|
private async Task ExecuteTestAsync(
|
|
string displayName,
|
|
string variableName)
|
|
{
|
|
// Arrange
|
|
MockAgentProvider mockAgentProvider = new();
|
|
|
|
RetrieveConversationMessage model = this.CreateModel(
|
|
this.FormatDisplayName(displayName),
|
|
FormatVariablePath(variableName),
|
|
"TestConversationId",
|
|
"DefaultMessageId");
|
|
|
|
RetrieveConversationMessageExecutor action = new(model, mockAgentProvider.Object, this.State);
|
|
|
|
// Act
|
|
await this.ExecuteAsync(action);
|
|
|
|
// Assert
|
|
ChatMessage? testMessage = mockAgentProvider.TestMessages?.FirstOrDefault();
|
|
Assert.NotNull(testMessage);
|
|
VerifyModel(model, action);
|
|
this.VerifyState(variableName, testMessage.ToRecord());
|
|
}
|
|
|
|
private RetrieveConversationMessage CreateModel(
|
|
string displayName,
|
|
string messageVariable,
|
|
string conversationId,
|
|
string messageId)
|
|
{
|
|
RetrieveConversationMessage.Builder actionBuilder =
|
|
new()
|
|
{
|
|
Id = this.CreateActionId(),
|
|
DisplayName = this.FormatDisplayName(displayName),
|
|
Message = PropertyPath.Create(messageVariable),
|
|
ConversationId = StringExpression.Literal(conversationId),
|
|
MessageId = StringExpression.Literal(messageId)
|
|
};
|
|
|
|
return AssignParent<RetrieveConversationMessage>(actionBuilder);
|
|
}
|
|
}
|