< Summary

Information
Class: Elsa.Testing.Shared.ActivityTestFixtureExtensions
Assembly: Elsa.Testing.Shared
File(s): /home/runner/work/elsa-core/elsa-core/src/common/Elsa.Testing.Shared/ActivityTestFixtureExtensions.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 10
Coverable lines: 10
Total lines: 43
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
AssertActivityAttributes(...)0%4260%

File(s)

/home/runner/work/elsa-core/elsa-core/src/common/Elsa.Testing.Shared/ActivityTestFixtureExtensions.cs

#LineLine coverage
 1using Elsa.Workflows;
 2using Elsa.Workflows.Attributes;
 3using Xunit;
 4
 5namespace Elsa.Testing.Shared;
 6
 7/// <summary>
 8/// General extension methods for ActivityTestFixture.
 9/// </summary>
 10public 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    {
 031        var activityType = fixture.Activity.GetType();
 032        var activityAttribute = activityType.GetCustomAttributes(typeof(ActivityAttribute), false)
 033            .Cast<ActivityAttribute>().FirstOrDefault();
 34
 035        Assert.NotNull(activityAttribute);
 036        Assert.Equal(expectedNamespace, activityAttribute.Namespace);
 037        Assert.Equal(expectedKind, activityAttribute.Kind);
 38
 039        if (expectedCategory != null) Assert.Equal(expectedCategory, activityAttribute.Category);
 040        if (expectedDescription != null) Assert.Equal(expectedDescription, activityAttribute.Description);
 041        if (expectedDisplayName != null) Assert.Equal(expectedDisplayName, activityAttribute.DisplayName);
 042    }
 43}