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.1 KiB
C#
70 lines
2.1 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System.Threading.Tasks;
|
|
using Microsoft.Agents.AI.Workflows.Declarative.ObjectModel;
|
|
using Microsoft.Agents.ObjectModel;
|
|
using Microsoft.PowerFx.Types;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Microsoft.Agents.AI.Workflows.Declarative.UnitTests.ObjectModel;
|
|
|
|
/// <summary>
|
|
/// Tests for <see cref="SetTextVariableExecutor"/>.
|
|
/// </summary>
|
|
public sealed class SetTextVariableExecutorTest(ITestOutputHelper output) : WorkflowActionExecutorTest(output)
|
|
{
|
|
[Fact]
|
|
public async Task SetLiteralValueAsync()
|
|
{
|
|
// Arrange
|
|
SetTextVariable model =
|
|
this.CreateModel(
|
|
this.FormatDisplayName(nameof(SetLiteralValueAsync)),
|
|
FormatVariablePath("TextVar"),
|
|
"Text variable value");
|
|
|
|
// Act
|
|
SetTextVariableExecutor action = new(model, this.State);
|
|
await this.ExecuteAsync(action);
|
|
|
|
// Assert
|
|
VerifyModel(model, action);
|
|
this.VerifyState("TextVar", FormulaValue.New("Text variable value"));
|
|
}
|
|
|
|
[Fact]
|
|
public async Task UpdateExistingValueAsync()
|
|
{
|
|
// Arrange
|
|
this.State.Set("TextVar", FormulaValue.New("Old value"));
|
|
|
|
SetTextVariable model =
|
|
this.CreateModel(
|
|
this.FormatDisplayName(nameof(UpdateExistingValueAsync)),
|
|
FormatVariablePath("TextVar"),
|
|
"New value");
|
|
|
|
// Act
|
|
SetTextVariableExecutor action = new(model, this.State);
|
|
await this.ExecuteAsync(action);
|
|
|
|
// Assert
|
|
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),
|
|
};
|
|
|
|
return AssignParent<SetTextVariable>(actionBuilder);
|
|
}
|
|
}
|