Enable more analyzers and various code tweaks/cleanup (#738)

This commit is contained in:
Stephen Toub
2025-09-18 01:48:25 +00:00
committed by GitHub
parent f3264966ff
commit 5e5761b288
326 changed files with 2402 additions and 3642 deletions
@@ -14,23 +14,23 @@ namespace Microsoft.Agents.Workflows.Declarative.UnitTests.Interpreter;
public sealed class DeclarativeWorkflowModelTest(ITestOutputHelper output) : WorkflowTest(output)
{
[Fact]
public async Task GetDepthForDefault()
public async Task GetDepthForDefaultAsync()
{
DeclarativeWorkflowModel model = new(this.CreateExecutor("root"));
DeclarativeWorkflowModel model = new(CreateExecutor("root"));
Assert.Equal(0, model.GetDepth(null));
}
[Fact]
public async Task GetDepthForMissingNode()
public async Task GetDepthForMissingNodeAsync()
{
DeclarativeWorkflowModel model = new(this.CreateExecutor("root"));
DeclarativeWorkflowModel model = new(CreateExecutor("root"));
Assert.Throws<DeclarativeModelException>(() => model.GetDepth("missing"));
}
[Fact]
public async Task ConnectMissingNode()
public async Task ConnectMissingNodeAsync()
{
TestExecutor rootExecutor = this.CreateExecutor("root");
TestExecutor rootExecutor = CreateExecutor("root");
DeclarativeWorkflowModel model = new(rootExecutor);
model.AddLink("root", "missing");
WorkflowBuilder workflowBuilder = new(rootExecutor);
@@ -38,36 +38,34 @@ public sealed class DeclarativeWorkflowModelTest(ITestOutputHelper output) : Wor
}
[Fact]
public async Task AddToMissingParent()
public async Task AddToMissingParentAsync()
{
DeclarativeWorkflowModel model = new(this.CreateExecutor("root"));
Assert.Throws<DeclarativeModelException>(() => model.AddNode(this.CreateExecutor("next"), "missing"));
DeclarativeWorkflowModel model = new(CreateExecutor("root"));
Assert.Throws<DeclarativeModelException>(() => model.AddNode(CreateExecutor("next"), "missing"));
}
[Fact]
public async Task LinkFromMissingSource()
public async Task LinkFromMissingSourceAsync()
{
DeclarativeWorkflowModel model = new(this.CreateExecutor("root"));
DeclarativeWorkflowModel model = new(CreateExecutor("root"));
Assert.Throws<DeclarativeModelException>(() => model.AddLink("missing", "anything"));
}
[Fact]
public async Task LocateMissingParent()
public async Task LocateMissingParentAsync()
{
DeclarativeWorkflowModel model = new(this.CreateExecutor("root"));
DeclarativeWorkflowModel model = new(CreateExecutor("root"));
Assert.Null(model.LocateParent<TestExecutor>(null));
Assert.Throws<DeclarativeModelException>(() => model.LocateParent<TestExecutor>("missing"));
}
private TestExecutor CreateExecutor(string id) => new(id);
private static TestExecutor CreateExecutor(string id) => new(id);
internal sealed class TestExecutor(string actionId) :
ReflectingExecutor<TestExecutor>(actionId),
IMessageHandler<string>
{
public async ValueTask HandleAsync(string message, IWorkflowContext context)
{
await context.SendMessageAsync($"{this.Id}: {DateTime.UtcNow.ToShortTimeString()}").ConfigureAwait(false);
}
public async ValueTask HandleAsync(string message, IWorkflowContext context) =>
await context.SendMessageAsync($"{this.Id}: {DateTime.UtcNow:t}").ConfigureAwait(false);
}
}