mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
fb513c38a6
* Checkpoint * Update workflows/DeepResearch.yaml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Comment * Fix comment * Update package version * Fix nuget haxx * Checkpoint * Code complete * Testing * Message content workaround * Add sequential flow * Checkpoint * Integration test project * Checkpoint * Checkpoint cleanup * Complete * Checkpoint * Fix tests * Comment cleanup * Namespace * Formatting * Analyzer updates * Workflow update * Fixed! * Update dotnet/tests/Microsoft.Agents.Workflows.Declarative.UnitTests/DeclarativeWorkflowTest.cs Co-authored-by: Tao Chen <taochen@microsoft.com> * Fix build error * Purge "immutable" set and dictionary * Fix as task * Collection expression * Another * Frozen => Readonly (perf) * Fix * Namespace --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Tao Chen <taochen@microsoft.com>
72 lines
2.2 KiB
C#
72 lines
2.2 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System.Threading.Tasks;
|
|
using Microsoft.Agents.Workflows.Declarative.ObjectModel;
|
|
using Microsoft.Bot.ObjectModel;
|
|
using Microsoft.PowerFx.Types;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Microsoft.Agents.Workflows.Declarative.UnitTests.ObjectModel;
|
|
|
|
/// <summary>
|
|
/// Tests for <see cref="SetTextVariableExecutor"/>.
|
|
/// </summary>
|
|
public sealed class SetTextVariableExecutorTest(ITestOutputHelper output) : WorkflowActionExecutorTest(output)
|
|
{
|
|
[Fact]
|
|
public async Task SetLiteralValue()
|
|
{
|
|
// Arrange
|
|
SetTextVariable model =
|
|
this.CreateModel(
|
|
this.FormatDisplayName(nameof(SetLiteralValue)),
|
|
FormatVariablePath("TextVar"),
|
|
"Text variable value");
|
|
|
|
// Act
|
|
SetTextVariableExecutor action = new(model, this.State);
|
|
await this.Execute(action);
|
|
|
|
// Assert
|
|
this.VerifyModel(model, action);
|
|
this.VerifyState("TextVar", FormulaValue.New("Text variable value"));
|
|
}
|
|
|
|
[Fact]
|
|
public async Task UpdateExistingValue()
|
|
{
|
|
// Arrange
|
|
this.State.Set("TextVar", FormulaValue.New("Old value"));
|
|
|
|
SetTextVariable model =
|
|
this.CreateModel(
|
|
this.FormatDisplayName(nameof(UpdateExistingValue)),
|
|
FormatVariablePath("TextVar"),
|
|
"New value");
|
|
|
|
// Act
|
|
SetTextVariableExecutor action = new(model, this.State);
|
|
await this.Execute(action);
|
|
|
|
// Assert
|
|
this.VerifyModel(model, action);
|
|
this.VerifyState("TextVar", FormulaValue.New("New value"));
|
|
}
|
|
|
|
private SetTextVariable CreateModel(string displayName, string variablePath, string textValue)
|
|
{
|
|
SetTextVariable.Builder actionBuilder =
|
|
new()
|
|
{
|
|
Id = this.CreateActionId(),
|
|
DisplayName = this.FormatDisplayName(displayName),
|
|
Variable = InitializablePropertyPath.Create(variablePath),
|
|
Value = TemplateLine.Parse(textValue),
|
|
};
|
|
|
|
SetTextVariable model = this.AssignParent<SetTextVariable>(actionBuilder);
|
|
|
|
return model;
|
|
}
|
|
}
|