< Summary

Class:Itinero.Instructions.Types.RouteExtensions
Assembly:Itinero.Instructions
File(s):/home/runner/work/routing2/routing2/src/Itinero.Instructions/Types/RouteExtensions.cs
Covered lines:10
Uncovered lines:2
Coverable lines:12
Total lines:33
Line coverage:83.3% (10 of 12)
Covered branches:5
Total branches:6
Branch coverage:83.3% (5 of 6)
Tag:224_14471318300

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
GetAttributeOrNull(...)83.33%683.33%

File(s)

/home/runner/work/routing2/routing2/src/Itinero.Instructions/Types/RouteExtensions.cs

#LineLine coverage
 1using Itinero.Routes;
 2
 3namespace Itinero.Instructions.Types;
 4
 5/// <summary>
 6/// Extensions on top of the route object to help with instruction generation.
 7/// </summary>
 8public static class RouteExtensions
 9{
 10    /// <summary>
 11    /// Gets the attribute or return a default value.
 12    /// </summary>
 13    /// <param name="meta">The meta route object.</param>
 14    /// <param name="key">The key of the attribute to get.</param>
 15    /// <returns>The value if any, null otherwise.</returns>
 16    public static string? GetAttributeOrNull(this Route.Meta? meta, string key)
 1717    {
 1718        if (meta == null)
 019        {
 020            return default;
 21        }
 22
 17823        foreach (var (k, value) in meta.Attributes)
 6824        {
 6825            if (k.Equals(key))
 926            {
 927                return value;
 28            }
 5929        }
 30
 831        return default;
 1732    }
 33}

Methods/Properties

GetAttributeOrNull(...)