| | | 1 | | using Elsa.Workflows; |
| | | 2 | | using Elsa.Workflows.Attributes; |
| | | 3 | | using Xunit; |
| | | 4 | | |
| | | 5 | | namespace Elsa.Testing.Shared; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// General extension methods for ActivityTestFixture. |
| | | 9 | | /// </summary> |
| | | 10 | | public static class ActivityTestFixtureExtensions |
| | | 11 | | { |
| | | 12 | | /// <summary> |
| | | 13 | | /// Validates that an activity has the expected attribute configuration. |
| | | 14 | | /// This is useful for ensuring activities are properly decorated with metadata. |
| | | 15 | | /// </summary> |
| | | 16 | | /// <param name="fixture">The test fixture (unused but enables extension method syntax)</param> |
| | | 17 | | /// <param name="expectedNamespace">Expected namespace (e.g., "Elsa")</param> |
| | | 18 | | /// /// <param name="expectedKind">Expected activity kind</param> |
| | | 19 | | /// <param name="expectedCategory">Expected category (e.g., "HTTP")</param> |
| | | 20 | | /// <param name="expectedDisplayName">Expected display name</param> |
| | | 21 | | /// <param name="expectedDescription">Expected description</param> |
| | | 22 | | public static void AssertActivityAttributes( |
| | | 23 | | this ActivityTestFixture fixture, |
| | | 24 | | string expectedNamespace, |
| | | 25 | | ActivityKind expectedKind, |
| | | 26 | | string? expectedCategory = null, |
| | | 27 | | string? expectedDisplayName = null, |
| | | 28 | | string? expectedDescription = null |
| | | 29 | | ) |
| | | 30 | | { |
| | 0 | 31 | | var activityType = fixture.Activity.GetType(); |
| | 0 | 32 | | var activityAttribute = activityType.GetCustomAttributes(typeof(ActivityAttribute), false) |
| | 0 | 33 | | .Cast<ActivityAttribute>().FirstOrDefault(); |
| | | 34 | | |
| | 0 | 35 | | Assert.NotNull(activityAttribute); |
| | 0 | 36 | | Assert.Equal(expectedNamespace, activityAttribute.Namespace); |
| | 0 | 37 | | Assert.Equal(expectedKind, activityAttribute.Kind); |
| | | 38 | | |
| | 0 | 39 | | if (expectedCategory != null) Assert.Equal(expectedCategory, activityAttribute.Category); |
| | 0 | 40 | | if (expectedDescription != null) Assert.Equal(expectedDescription, activityAttribute.Description); |
| | 0 | 41 | | if (expectedDisplayName != null) Assert.Equal(expectedDisplayName, activityAttribute.DisplayName); |
| | 0 | 42 | | } |
| | | 43 | | } |