< Summary

Information
Class: Elsa.Http.Services.RouteMatcher
Assembly: Elsa.Http
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Http/Services/RouteMatcher.cs
Line coverage
88%
Covered lines: 8
Uncovered lines: 1
Coverable lines: 9
Total lines: 31
Line coverage: 88.8%
Branch coverage
83%
Covered branches: 5
Total branches: 6
Branch coverage: 83.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Match(...)100%22100%
GetDefaults(...)75%4480%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Http/Services/RouteMatcher.cs

#LineLine coverage
 1// Taken & adapted from https://github.com/markvincze/Stubbery/blob/main/src/Stubbery/RequestMatching/RouteMatcher.cs
 2
 3using Microsoft.AspNetCore.Routing;
 4using Microsoft.AspNetCore.Routing.Template;
 5
 6namespace Elsa.Http.Services;
 7
 8/// <inheritdoc />
 9public class RouteMatcher : IRouteMatcher
 10{
 11    /// <inheritdoc />
 12    public RouteValueDictionary? Match(string routeTemplate, string route)
 13    {
 153714        var template = TemplateParser.Parse(routeTemplate);
 153715        var matcher = new TemplateMatcher(template, GetDefaults(template));
 153716        var values = new RouteValueDictionary();
 17
 153718        return matcher.TryMatch(route, values) ? values : null;
 19    }
 20
 21    private static RouteValueDictionary GetDefaults(RouteTemplate parsedTemplate)
 22    {
 153723        var result = new RouteValueDictionary();
 24
 314825        foreach (var parameter in parsedTemplate.Parameters)
 3726            if (parameter.DefaultValue != null)
 027                result.Add(parameter.Name!, parameter.DefaultValue);
 28
 153729        return result;
 30    }
 31}