< Summary

Class:Itinero.Profiles.Lua.Osm.OsmProfiles
Assembly:Itinero.Profiles.Lua
File(s):/home/runner/work/routing2/routing2/src/Itinero.Profiles.Lua/Osm/OsmProfiles.cs
Covered lines:18
Uncovered lines:0
Coverable lines:18
Total lines:53
Line coverage:100% (18 of 18)
Covered branches:1
Total branches:2
Branch coverage:50% (1 of 2)
Tag:224_14471318300

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.cctor()100%1100%
get_Bicycle()100%1100%
get_Pedestrian()100%1100%
get_Car()100%1100%
get_CarShort()100%1100%
LoadEmbeddedResource(...)50%2100%

File(s)

/home/runner/work/routing2/routing2/src/Itinero.Profiles.Lua/Osm/OsmProfiles.cs

#LineLine coverage
 1using System;
 2using System.IO;
 3
 4namespace Itinero.Profiles.Lua.Osm;
 5
 6/// <summary>
 7/// Contains a few default embedded OSM profiles.
 8/// </summary>
 9public static class OsmProfiles
 10{
 211    private static readonly Lazy<Profile> LazyBicycle = new(() => LuaProfile.Load(LoadEmbeddedResource("Itinero.Profiles
 212        "Itinero.Profiles.Lua.Osm.bicycle.lua"));
 13
 14    /// <summary>
 15    /// Gets the default bicycle profile.
 16    /// </summary>
 617    public static Profile Bicycle { get; } = LazyBicycle.Value;
 18
 219    private static readonly Lazy<Profile> LazyPedestrian = new(() => LuaProfile.Load(LoadEmbeddedResource("Itinero.Profi
 220        "Itinero.Profiles.Lua.Osm.pedestrian.lua"));
 21
 22    /// <summary>
 23    /// Gets the default pedestrian profile.
 24    /// </summary>
 125    public static Profile Pedestrian { get; } = LazyPedestrian.Value;
 26
 227    private static readonly Lazy<Profile> LazyCar = new(() => LuaProfile.Load(LoadEmbeddedResource("Itinero.Profiles.Lua
 228        "Itinero.Profiles.Lua.Osm.car.lua"));
 29
 30    /// <summary>
 31    /// Gets the default car profile.
 32    /// </summary>
 133    public static Profile Car { get; } = LazyCar.Value;
 34
 235    private static readonly Lazy<Profile> LazyCarShort = new(() => LuaProfile.Load(LoadEmbeddedResource("Itinero.Profile
 236        "Itinero.Profiles.Lua.Osm.car.short.lua"));
 37
 38    /// <summary>
 39    /// Gets the car short profile.
 40    /// </summary>
 141    public static Profile CarShort { get; } = LazyCarShort.Value;
 42
 43    /// <summary>
 44    /// Loads a string from an embedded resource stream.
 45    /// </summary>
 46    private static string LoadEmbeddedResource(string name)
 447    {
 448        using var stream = typeof(LuaProfile).Assembly.GetManifestResourceStream(name);
 449        if (stream == null) throw new Exception($"Profile {name} not found.");
 450        using var streamReader = new StreamReader(stream);
 451        return streamReader.ReadToEnd();
 452    }
 53}