Files
wehub-resource-sync db620d33df
CodeQL / Analyze (csharp) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
dotnet-build-and-test / dotnet-test-functions (push) Has been cancelled
dotnet-build-and-test / paths-filter (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Debug, windows-latest, net9.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net8.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-foundry-hosted-it (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test-check (push) Has been cancelled
dotnet-build-and-test / Integration Test Report (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:39:25 +08:00

81 lines
2.1 KiB
C#

// Copyright (c) Microsoft. All rights reserved.
using System.Collections.Generic;
using Microsoft.Agents.AI.Workflows.Declarative.PowerFx;
using Microsoft.PowerFx;
namespace Microsoft.Agents.AI.Workflows.Declarative.UnitTests.PowerFx;
public class RecalcEngineFactoryTests(ITestOutputHelper output) : WorkflowTest(output)
{
[Fact]
public void DefaultNotNull()
{
// Act
RecalcEngine engine = RecalcEngineFactory.Create();
// Assert
Assert.NotNull(engine);
}
[Fact]
public void NewInstanceEachTime()
{
// Act
RecalcEngine engine1 = RecalcEngineFactory.Create();
RecalcEngine engine2 = RecalcEngineFactory.Create();
// Assert
Assert.NotNull(engine1);
Assert.NotNull(engine2);
Assert.NotSame(engine1, engine2);
}
[Fact]
public void HasSetFunctionEnabled()
{
// Arrange
RecalcEngine engine = RecalcEngineFactory.Create();
// Act
CheckResult result = engine.Check("1+1");
// Assert
Assert.True(result.IsSuccess);
}
[Fact]
public void HasCorrectMaximumExpressionLength()
{
// Arrange
RecalcEngine engine = RecalcEngineFactory.Create(2000, 3);
// Assert
Assert.Equal(2000, engine.Config.MaximumExpressionLength);
Assert.Equal(3, engine.Config.MaxCallDepth);
// Act: Create a long expression that is within the limit
string goodExpression = string.Concat(GenerateExpression(999));
CheckResult goodResult = engine.Check(goodExpression);
// Assert
Assert.True(goodResult.IsSuccess);
// Act: Create a long expression that exceeds the limit
string longExpression = string.Concat(GenerateExpression(1001));
CheckResult longResult = engine.Check(longExpression);
// Assert
Assert.False(longResult.IsSuccess);
static IEnumerable<string> GenerateExpression(int elements)
{
yield return "1";
for (int i = 0; i < elements - 1; i++)
{
yield return "+1";
}
}
}
}