Summary

Class:WireMock.Handlers.LocalFileSystemHandler
Assembly:WireMock.Net
File(s):C:\Users\StefHeyenrath\Documents\GitHub\WireMock.Net\src\WireMock.Net\Handlers\LocalFileSystemHandler.cs
Covered lines:20
Uncovered lines:5
Coverable lines:25
Total lines:62
Line coverage:80%

Metrics

MethodCyclomatic complexity NPath complexity Sequence coverage Branch coverage
FolderExists(...)0010
CreateFolder(...)000.50
EnumerateFiles(...)0010
GetMappingFolder()0010
ReadMappingFile(...)0010
WriteMappingFile(...)000.40
.cctor()0010

File(s)

C:\Users\StefHeyenrath\Documents\GitHub\WireMock.Net\src\WireMock.Net\Handlers\LocalFileSystemHandler.cs

#LineLine coverage
 1using System.Collections.Generic;
 2using System.IO;
 3using JetBrains.Annotations;
 4using WireMock.Validation;
 5
 6namespace WireMock.Handlers
 7{
 8    /// <summary>
 9    /// Default implementation for a handler to interact with the local file system to read and write static mapping fil
 10    /// </summary>
 11    public class LocalFileSystemHandler : IFileSystemHandler
 12    {
 113        private static readonly string AdminMappingsFolder = Path.Combine("__admin", "mappings");
 14
 15        /// <inheritdoc cref="IFileSystemHandler.FolderExists"/>
 16        public bool FolderExists([NotNull] string path)
 317        {
 318            Check.NotNullOrEmpty(path, nameof(path));
 19
 320            return Directory.Exists(path);
 321        }
 22
 23        /// <inheritdoc cref="IFileSystemHandler.CreateFolder"/>
 24        public void CreateFolder([NotNull] string path)
 125        {
 126            Check.NotNullOrEmpty(path, nameof(path));
 27
 028            Directory.CreateDirectory(path);
 029        }
 30
 31        /// <inheritdoc cref="IFileSystemHandler.EnumerateFiles"/>
 32        public IEnumerable<string> EnumerateFiles([NotNull] string path)
 233        {
 234            Check.NotNullOrEmpty(path, nameof(path));
 35
 236            return Directory.EnumerateFiles(path);
 237        }
 38
 39        /// <inheritdoc cref="IFileSystemHandler.GetMappingFolder"/>
 40        public string GetMappingFolder()
 141        {
 142            return Path.Combine(Directory.GetCurrentDirectory(), AdminMappingsFolder);
 143        }
 44
 45        /// <inheritdoc cref="IFileSystemHandler.ReadMappingFile"/>
 46        public string ReadMappingFile([NotNull] string path)
 947        {
 948            Check.NotNullOrEmpty(path, nameof(path));
 49
 950            return File.ReadAllText(path);
 951        }
 52
 53        /// <inheritdoc cref="IFileSystemHandler.WriteMappingFile"/>
 54        public void WriteMappingFile([NotNull] string path, [NotNull] string text)
 155        {
 156            Check.NotNullOrEmpty(path, nameof(path));
 057            Check.NotNull(text, nameof(text));
 58
 059            File.WriteAllText(path, text);
 060        }
 61    }
 62}