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

142 lines
3.3 KiB
C#

// Copyright (c) Microsoft. All rights reserved.
using System.Collections.Generic;
using Microsoft.Agents.AI.Workflows.Declarative.Extensions;
using Microsoft.Agents.ObjectModel;
using Microsoft.PowerFx;
namespace Microsoft.Agents.AI.Workflows.Declarative.UnitTests.Extensions;
public sealed class TemplateExtensionsTests
{
[Fact]
public void FormatTemplateWithTextSegments()
{
// Arrange
RecalcEngine engine = new();
IEnumerable<TemplateLine> template =
[
new TemplateLine.Builder
{
Segments =
{
new TextSegment.Builder { Value = "Hello " },
new TextSegment.Builder { Value = "World" }
}
}.Build()
];
// Act
string result = engine.Format(template);
// Assert
Assert.Equal("Hello World", result);
}
[Fact]
public void FormatTemplateWithMultipleLines()
{
// Arrange
RecalcEngine engine = new();
IEnumerable<TemplateLine> template =
[
new TemplateLine.Builder
{
Segments =
{
new TextSegment.Builder { Value = "Line 1" }
}
}.Build(),
new TemplateLine.Builder
{
Segments =
{
new TextSegment.Builder { Value = "Line 2" }
}
}.Build()
];
// Act
string result = engine.Format(template);
// Assert
Assert.Equal("Line 1Line 2", result);
}
[Fact]
public void FormatSingleTemplateLineWithNullValue()
{
// Arrange
RecalcEngine engine = new();
TemplateLine? line = null;
// Act
string result = engine.Format(line);
// Assert
Assert.Equal(string.Empty, result);
}
[Fact]
public void FormatSingleTemplateLineWithTextSegment()
{
// Arrange
RecalcEngine engine = new();
TemplateLine line = new TemplateLine.Builder
{
Segments =
{
new TextSegment.Builder { Value = "Test" }
}
}.Build();
// Act
string result = engine.Format(line);
// Assert
Assert.Equal("Test", result);
}
[Fact]
public void FormatTextSegmentWithNullValue()
{
// Arrange
RecalcEngine engine = new();
TextSegment segment = new TextSegment.Builder { Value = null }.Build();
// Act
string result = engine.Format(segment);
// Assert
Assert.Equal(string.Empty, result);
}
[Fact]
public void FormatTextSegmentWithEmptyValue()
{
// Arrange
RecalcEngine engine = new();
TextSegment segment = new TextSegment.Builder { Value = "" }.Build();
// Act
string result = engine.Format(segment);
// Assert
Assert.Equal(string.Empty, result);
}
[Fact]
public void FormatTextSegmentWithValue()
{
// Arrange
RecalcEngine engine = new();
TextSegment segment = new TextSegment.Builder { Value = "Hello World" }.Build();
// Act
string result = engine.Format(segment);
// Assert
Assert.Equal("Hello World", result);
}
}