Files
agent-framework/dotnet/tests/Microsoft.Agents.Workflows.UnitTests/MessagingTestHelpers.cs
T
Jacob Alber e1147273da .NET: fix: FanIn Edge does not work (#541)
* fix: FanIn Edge does not work

We were not creating the state for FanIn edge in EdgeMap correctly, leading to crashes. After fixing that, it turns out the logic in FanInEdgeRunner was only forwarding the last message, not all of them.

* fix: Remove duplicate code and fix typo
2025-08-28 22:25:57 +00:00

41 lines
1.6 KiB
C#

// Copyright (c) Microsoft. All rights reserved.
using System;
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
using Microsoft.Agents.Workflows.Execution;
// Copyright (c) Microsoft. All rights reserved.
namespace Microsoft.Agents.Workflows.UnitTests;
internal static class MessagingTestHelpers
{
private static void CheckForwarded(Dictionary<string, List<MessageEnvelope>> queuedMessages, params (string expectedSender, List<string> expectedMessages)[] expectedForwards)
{
queuedMessages.Should().HaveCount(expectedForwards.Length);
IEnumerable<Action<string>> perSenderValidations = expectedForwards.Select(
(forward) =>
{
(string expectedSender, List<string> expectedMessages) = forward;
return (Action<string>)(
(string senderId) =>
{
senderId.Should().Be(expectedSender);
queuedMessages[senderId].Should().HaveCount(expectedMessages.Count);
Action<MessageEnvelope>[] validations
= expectedMessages.Select(message => (Action<MessageEnvelope>)(envelope => envelope!.Message.Should().Be(message)))
.ToArray();
Assert.Collection(queuedMessages[senderId], validations);
});
}
);
Assert.Collection(queuedMessages.Keys, perSenderValidations.ToArray());
}
}