< Summary

Line coverage
50%
Covered lines: 11
Uncovered lines: 11
Coverable lines: 22
Total lines: 127
Line coverage: 50%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
File 1: PathNormalize(...)0%20%
File 1: PathEquals(...)100%10%
File 1: PathStartsWith(...)100%10%
File 2: PathNormalize(...)100%2100%
File 2: PathEquals(...)100%1100%
File 2: PathStartsWith(...)100%1100%

File(s)

C:\projects\jeremyansel-io-locator\JeremyAnsel.IO.Locator\JeremyAnsel.IO.Locator\Utilities.cs

#LineLine coverage
 1// <copyright file="Utilities.cs" company="Jérémy Ansel">
 2// Copyright (c) 2015, 2019 Jérémy Ansel
 3// </copyright>
 4// <license>
 5// Licensed under the MIT license. See LICENSE.txt
 6// </license>
 7
 8namespace JeremyAnsel.IO.Locator
 9{
 10    using System;
 11    using System.IO;
 12
 13    /// <summary>
 14    /// Utility methods.
 15    /// </summary>
 16    internal static class Utilities
 17    {
 18        /// <summary>
 19        /// Normalizes a path.
 20        /// </summary>
 21        /// <param name="path">The path.</param>
 22        /// <returns>A normalized path.</returns>
 23        public static string PathNormalize(string path)
 24        {
 025            if (string.IsNullOrEmpty(path))
 26            {
 027                return string.Empty;
 28            }
 29
 030            return path
 031                .Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar)
 032                .TrimStart(Path.DirectorySeparatorChar);
 33        }
 34
 35        /// <summary>
 36        /// Indicates whether two paths are equals.
 37        /// </summary>
 38        /// <param name="path1">The first path.</param>
 39        /// <param name="path2">The second path.</param>
 40        /// <returns>A boolean.</returns>
 41        public static bool PathEquals(string path1, string path2)
 42        {
 043            path1 = Utilities.PathNormalize(path1);
 044            path2 = Utilities.PathNormalize(path2);
 45
 046            return string.Equals(path1, path2, StringComparison.OrdinalIgnoreCase);
 47        }
 48
 49        /// <summary>
 50        /// Indicates whether a path starts with a specified path.
 51        /// </summary>
 52        /// <param name="path1">The first path.</param>
 53        /// <param name="path2">The second path.</param>
 54        /// <returns>A boolean.</returns>
 55        public static bool PathStartsWith(string path1, string path2)
 56        {
 057            path1 = Utilities.PathNormalize(path1);
 058            path2 = Utilities.PathNormalize(path2);
 59
 060            return path1.StartsWith(path2, StringComparison.OrdinalIgnoreCase);
 61        }
 62    }
 63}

https://raw.githubusercontent.com/JeremyAnsel/JeremyAnsel.IO.Locator/16c8f4344390c6376cd2208cc1ae63a39862df37/JeremyAnsel.IO.Locator/JeremyAnsel.IO.Locator/Utilities.cs

#LineLine coverage
 1// <copyright file="Utilities.cs" company="Jérémy Ansel">
 2// Copyright (c) 2015, 2019 Jérémy Ansel
 3// </copyright>
 4// <license>
 5// Licensed under the MIT license. See LICENSE.txt
 6// </license>
 7
 8namespace JeremyAnsel.IO.Locator
 9{
 10    using System;
 11    using System.IO;
 12
 13    /// <summary>
 14    /// Utility methods.
 15    /// </summary>
 16    internal static class Utilities
 17    {
 18        /// <summary>
 19        /// Normalizes a path.
 20        /// </summary>
 21        /// <param name="path">The path.</param>
 22        /// <returns>A normalized path.</returns>
 23        public static string PathNormalize(string path)
 24        {
 3625            if (string.IsNullOrEmpty(path))
 26            {
 827                return string.Empty;
 28            }
 29
 2830            return path
 2831                .Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar)
 2832                .TrimStart(Path.DirectorySeparatorChar);
 33        }
 34
 35        /// <summary>
 36        /// Indicates whether two paths are equals.
 37        /// </summary>
 38        /// <param name="path1">The first path.</param>
 39        /// <param name="path2">The second path.</param>
 40        /// <returns>A boolean.</returns>
 41        public static bool PathEquals(string path1, string path2)
 42        {
 243            path1 = Utilities.PathNormalize(path1);
 244            path2 = Utilities.PathNormalize(path2);
 45
 246            return string.Equals(path1, path2, StringComparison.OrdinalIgnoreCase);
 47        }
 48
 49        /// <summary>
 50        /// Indicates whether a path starts with a specified path.
 51        /// </summary>
 52        /// <param name="path1">The first path.</param>
 53        /// <param name="path2">The second path.</param>
 54        /// <returns>A boolean.</returns>
 55        public static bool PathStartsWith(string path1, string path2)
 56        {
 857            path1 = Utilities.PathNormalize(path1);
 858            path2 = Utilities.PathNormalize(path2);
 59
 860            return path1.StartsWith(path2, StringComparison.OrdinalIgnoreCase);
 61        }
 62    }
 63}
 64