mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
647db9635a
* Renaming Microsoft.Agent.Workflows to Microsoft.Agents.AI.Workflows * Removing local settings. * Removing remining old files from merge.
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.AI.Workflows.Declarative.ObjectModel;
|
|
using Microsoft.Bot.ObjectModel;
|
|
using Microsoft.PowerFx.Types;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Microsoft.Agents.AI.Workflows.Declarative.UnitTests.ObjectModel;
|
|
|
|
/// <summary>
|
|
/// Tests for <see cref="ClearAllVariablesExecutor"/>.
|
|
/// </summary>
|
|
public sealed class ClearAllVariablesExecutorTest(ITestOutputHelper output) : WorkflowActionExecutorTest(output)
|
|
{
|
|
[Fact]
|
|
public async Task ClearWorkflowScopeAsync()
|
|
{
|
|
// Arrange
|
|
this.State.Set("NoVar", FormulaValue.New("Old value"));
|
|
this.State.Bind();
|
|
|
|
ClearAllVariables model =
|
|
this.CreateModel(
|
|
this.FormatDisplayName(nameof(ClearWorkflowScopeAsync)),
|
|
VariablesToClear.ConversationScopedVariables);
|
|
|
|
// Act
|
|
ClearAllVariablesExecutor action = new(model, this.State);
|
|
await this.ExecuteAsync(action);
|
|
|
|
// Assert
|
|
VerifyModel(model, action);
|
|
this.VerifyUndefined("NoVar");
|
|
}
|
|
|
|
[Fact]
|
|
public async Task ClearUndefinedScopeAsync()
|
|
{
|
|
// Arrange
|
|
this.State.Set("NoVar", FormulaValue.New("Old value"));
|
|
this.State.Bind();
|
|
|
|
// Arrange
|
|
ClearAllVariables model =
|
|
this.CreateModel(
|
|
this.FormatDisplayName(nameof(ClearUndefinedScopeAsync)),
|
|
VariablesToClear.UserScopedVariables);
|
|
|
|
// Act
|
|
ClearAllVariablesExecutor action = new(model, this.State);
|
|
await this.ExecuteAsync(action);
|
|
|
|
// Assert
|
|
VerifyModel(model, action);
|
|
this.VerifyState("NoVar", FormulaValue.New("Old value"));
|
|
}
|
|
|
|
private ClearAllVariables CreateModel(string displayName, VariablesToClear variableTarget)
|
|
{
|
|
ClearAllVariables.Builder actionBuilder =
|
|
new()
|
|
{
|
|
Id = this.CreateActionId(),
|
|
DisplayName = this.FormatDisplayName(displayName),
|
|
Variables = EnumExpression<VariablesToClearWrapper>.Literal(VariablesToClearWrapper.Get(variableTarget)),
|
|
};
|
|
|
|
return AssignParent<ClearAllVariables>(actionBuilder);
|
|
}
|
|
}
|