From 5cc2a7c75a399ed774eb59b3d236ede8a1df25f5 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Sun, 21 Jun 2026 23:18:28 +0200 Subject: [PATCH 1/2] Fix publish event payload assertion casing Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Primitives/Event/PublishEventTests.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Primitives/Event/PublishEventTests.cs b/test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Primitives/Event/PublishEventTests.cs index b1390b510..18782b151 100644 --- a/test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Primitives/Event/PublishEventTests.cs +++ b/test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Primitives/Event/PublishEventTests.cs @@ -74,10 +74,25 @@ public class PublishEventTests : AppComponentTest // Verify the payload structure and content using var payloadDocument = JsonDocument.Parse(JsonSerializer.Serialize(receivedPayload)); - Assert.True(payloadDocument.RootElement.TryGetProperty("Status", out var status), "Received payload should contain a Status property"); + Assert.True(TryGetProperty(payloadDocument.RootElement, "Status", out var status), "Received payload should contain a Status property"); Assert.Equal("Shipped", status.GetString()); } + private static bool TryGetProperty(JsonElement element, string propertyName, out JsonElement value) + { + foreach (var property in element.EnumerateObject()) + { + if (string.Equals(property.Name, propertyName, StringComparison.OrdinalIgnoreCase)) + { + value = property.Value; + return true; + } + } + + value = default; + return false; + } + private async Task GetSingleWorkflowInstanceAsync(string definitionId, string correlationId, int timeoutMs = 5000) { var tcs = new TaskCompletionSource(); From d5378d6ef90277a1747bb1f37889f50bb9e0da63 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Tue, 23 Jun 2026 02:22:54 +0200 Subject: [PATCH 2/2] Address payload assertion review feedback Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Primitives/Event/PublishEventTests.cs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Primitives/Event/PublishEventTests.cs b/test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Primitives/Event/PublishEventTests.cs index 18782b151..d4358cc91 100644 --- a/test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Primitives/Event/PublishEventTests.cs +++ b/test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Primitives/Event/PublishEventTests.cs @@ -1,3 +1,4 @@ +using System.Linq; using System.Text.Json; using Elsa.Common.Models; using Elsa.Testing.Shared; @@ -80,17 +81,13 @@ public class PublishEventTests : AppComponentTest private static bool TryGetProperty(JsonElement element, string propertyName, out JsonElement value) { - foreach (var property in element.EnumerateObject()) - { - if (string.Equals(property.Name, propertyName, StringComparison.OrdinalIgnoreCase)) - { - value = property.Value; - return true; - } - } + value = element + .EnumerateObject() + .Where(property => string.Equals(property.Name, propertyName, StringComparison.OrdinalIgnoreCase)) + .Select(property => property.Value) + .FirstOrDefault(); - value = default; - return false; + return value.ValueKind != JsonValueKind.Undefined; } private async Task GetSingleWorkflowInstanceAsync(string definitionId, string correlationId, int timeoutMs = 5000)