mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
e1147273da
* 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
41 lines
1.6 KiB
C#
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());
|
|
}
|
|
}
|