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>
69 lines
2.1 KiB
C#
69 lines
2.1 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="ClearAllVariablesExecutor"/>.
|
|
/// </summary>
|
|
public sealed class ClearAllVariablesExecutorTest(ITestOutputHelper output) : WorkflowActionExecutorTest(output)
|
|
{
|
|
[Fact]
|
|
public async Task ClearWorkflowScope()
|
|
{
|
|
// Arrange
|
|
this.State.Set("NoVar", FormulaValue.New("Old value"));
|
|
|
|
ClearAllVariables model =
|
|
this.CreateModel(
|
|
this.FormatDisplayName(nameof(ClearWorkflowScope)),
|
|
VariablesToClear.ConversationScopedVariables);
|
|
|
|
// Act
|
|
ClearAllVariablesExecutor action = new(model, this.State);
|
|
await this.Execute(action);
|
|
|
|
// Assert
|
|
this.VerifyModel(model, action);
|
|
this.VerifyUndefined("NoVar");
|
|
}
|
|
|
|
[Fact]
|
|
public async Task ClearUndefinedScope()
|
|
{
|
|
// Arrange
|
|
ClearAllVariables model =
|
|
this.CreateModel(
|
|
this.FormatDisplayName(nameof(ClearUndefinedScope)),
|
|
VariablesToClear.UserScopedVariables);
|
|
|
|
// Act
|
|
ClearAllVariablesExecutor action = new(model, this.State);
|
|
await this.Execute(action);
|
|
|
|
// Assert
|
|
this.VerifyModel(model, action);
|
|
this.VerifyUndefined("NoVar");
|
|
}
|
|
|
|
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)),
|
|
};
|
|
|
|
ClearAllVariables model = this.AssignParent<ClearAllVariables>(actionBuilder);
|
|
|
|
return model;
|
|
}
|
|
}
|