< Summary

Information
Class: Elsa.Workflows.Pipelines.MiddlewareHelpers
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Pipelines/MiddlewareHelpers.cs
Line coverage
66%
Covered lines: 6
Uncovered lines: 3
Coverable lines: 9
Total lines: 29
Line coverage: 66.6%
Branch coverage
60%
Covered branches: 6
Total branches: 10
Branch coverage: 60%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetInvokeMethod(...)60%141066.66%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Pipelines/MiddlewareHelpers.cs

#LineLine coverage
 1using System.Reflection;
 2
 3namespace Elsa.Workflows.Pipelines;
 4
 5public static class MiddlewareHelpers
 6{
 7    public static MethodInfo GetInvokeMethod(Type middleware)
 8    {
 9        const string invokeMethodName = "Invoke";
 10        const string invokeAsyncMethodName = "InvokeAsync";
 423011        var methods = middleware.GetMethods(BindingFlags.Instance | BindingFlags.Public);
 2538012        var invokeMethods = methods.Where(m => string.Equals(m.Name, invokeMethodName, StringComparison.Ordinal) || stri
 13
 423014        switch (invokeMethods.Length)
 15        {
 16            case > 1:
 017                throw new InvalidOperationException("Multiple Invoke methods were found. Use either Invoke or InvokeAsyn
 18            case 0:
 019                throw new InvalidOperationException("No Invoke methods were found. Use either Invoke or InvokeAsync");
 20        }
 21
 423022        var methodInfo = invokeMethods[0];
 23
 423024        if (!typeof(Task).IsAssignableFrom(methodInfo.ReturnType) && !typeof(ValueTask).IsAssignableFrom(methodInfo.Retu
 025            throw new InvalidOperationException($"The {methodInfo.Name} method must return Task or ValueTask");
 26
 423027        return methodInfo;
 28    }
 29}

Methods/Properties

GetInvokeMethod(System.Type)