< Summary

Class:Mklinker.Commands.RemoveLinkCommand
Assembly:Mklinker
File(s):/home/travis/build/rubenchristoffer/Mklinker/Mklinker/Commands/RemoveLinkCommand.cs
Covered lines:15
Uncovered lines:4
Coverable lines:19
Total lines:41
Line coverage:78.9% (15 of 19)
Covered branches:3
Total branches:4
Branch coverage:75% (3 of 4)

Metrics

MethodCyclomatic complexity NPath complexity Sequence coverage Branch coverage
.ctor()100%100%
.ctor(...)10100%100%
Execute(...)4078.57%75%

File(s)

/home/travis/build/rubenchristoffer/Mklinker/Mklinker/Commands/RemoveLinkCommand.cs

#LineLine coverage
 1using System;
 2using System.Linq;
 3using System.IO.Abstractions;
 4using CommandLine;
 5using Mklinker.Abstractions;
 6
 7namespace Mklinker.Commands {
 8
 9  [Verb("removelink", HelpText = "Removes link from config")]
 10  class RemoveLinkCommand : GlobalOptions {
 11
 12    [Value(0, HelpText = "The targetPath matching entry you want to delete from config.", MetaName = "targetPath", Requi
 713    public string targetPath { get; private set; }
 14
 015    public RemoveLinkCommand() : base() { }
 16
 417    public RemoveLinkCommand(string targetPath, string path) : base(path) {
 218      this.targetPath = targetPath;
 219    }
 20
 221    internal void Execute(IConsole console, IConfigHandler configHandler, IFileSystem fileSystem, IPathResolver pathReso
 022      if (!configHandler.DoesConfigExist(path)) {
 023        console.WriteLine($"Config '{ path }' does not exist. Type 'help config' in order to see how you create a config
 024        return;
 25      }
 26
 227      IConfig config = configHandler.LoadConfig(path);
 528      ConfigLink configLink = config.LinkList.FirstOrDefault(link => pathResolver.GetAbsoluteResolvedPath(link.targetPat
 29
 330      if (configLink != null) {
 131        config.LinkList.Remove(configLink);
 132        console.WriteLine("\nSuccessfully removed link with targetPath '{0}'", targetPath);
 33
 134        configHandler.SaveConfig(config, path);
 235      } else {
 136        console.WriteLine($"\nThe targetPath '{targetPath}' is invalid because it does not exist in config", IConsole.Co
 137      }
 238    }
 39
 40  }
 41}