From d5378d6ef90277a1747bb1f37889f50bb9e0da63 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Tue, 23 Jun 2026 02:22:54 +0200 Subject: [PATCH] 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)