< Summary

Class:Mklinker.PathResolver
Assembly:Mklinker
File(s):/home/travis/build/rubenchristoffer/Mklinker/Mklinker/PathResolver.cs
Covered lines:15
Uncovered lines:0
Coverable lines:15
Total lines:41
Line coverage:100% (15 of 15)
Covered branches:4
Total branches:4
Branch coverage:100% (4 of 4)

Metrics

MethodCyclomatic complexity NPath complexity Sequence coverage Branch coverage
.cctor()10100%100%
.ctor(...)10100%100%
GetAbsoluteResolvedPath(...)40100%100%

File(s)

/home/travis/build/rubenchristoffer/Mklinker/Mklinker/PathResolver.cs

#LineLine coverage
 1using System;
 2using System.Linq;
 3using Mklinker.Abstractions;
 4using System.IO.Abstractions;
 5using System.Collections.Generic;
 6using System.Text.RegularExpressions;
 7
 8namespace Mklinker {
 9
 10  class PathResolver : IPathResolver {
 11
 12    public const string delimiter = "?";
 113    public static readonly string regex = $@"{ Regex.Escape(delimiter) }[^?]*{ Regex.Escape(delimiter) }";
 14
 15    readonly IFileSystem fileSystem;
 16
 1017    public PathResolver (IFileSystem fileSystem) {
 518      this.fileSystem = fileSystem;
 519    }
 20
 521    public string GetAbsoluteResolvedPath(string unresolvedPath, IEnumerable<Variable> variables) {
 522      string resolvedPath = unresolvedPath;
 23
 24      Match match;
 25
 1726      while ((match = Regex.Match(resolvedPath, regex)).Success) {
 727        string name = match.Value;
 1628        Variable matchedVariables = variables.FirstOrDefault(variable => (delimiter + variable.name + delimiter).Equals(
 29
 730        if (matchedVariables == null)
 231          break;
 32
 533        resolvedPath = resolvedPath.Replace(name, matchedVariables.value, StringComparison.OrdinalIgnoreCase);
 534      }
 35
 536      return fileSystem.Path.GetFullPath(resolvedPath.Replace(@"\", "/")).Replace(@"\", "/");
 537    }
 38
 39  }
 40
 41}