• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MeindertN / RoboClerk / 19481929392

18 Nov 2025 10:05PM UTC coverage: 72.65% (+0.3%) from 72.366%
19481929392

push

github

MeindertN
Fixed failing test

2217 of 3233 branches covered (68.57%)

Branch coverage included in aggregate %.

4 of 4 new or added lines in 1 file covered. (100.0%)

526 existing lines in 15 files now uncovered.

6894 of 9308 relevant lines covered (74.07%)

96.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

55.16
/RoboClerk.Core/LocalFileSystemPlugin.cs
1
using System;
2
using System.IO;
3
using System.IO.Abstractions;
4
using System.Linq;
5
using Microsoft.Extensions.DependencyInjection;
6
using RoboClerk.Core.Configuration;
7
using System.Collections.Generic;
8
using System.Threading.Tasks;
9

10
namespace RoboClerk
11
{
12
    /// <summary>
13
    /// Local filesystem implementation of the file provider plugin.
14
    /// This provides access to the local file system using System.IO.Abstractions for better testability.
15
    /// </summary>
16
    public class LocalFileSystemPlugin : FileProviderPluginBase, IFileProviderPlugin
17
    {
18
        private readonly IFileSystem _fileSystem;
19

20
        public LocalFileSystemPlugin(IFileSystem fileSystem)
218✔
21
        {
218✔
22
            _fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem));
218✔
23
            name = "LocalFileSystemPlugin";
217✔
24
            description = "Provides access to the local file system using standard .NET IO operations.";
217✔
25
        }
217✔
26

27
        public override void InitializePlugin(IConfiguration configuration)
28
        {
×
29
            LogInfo("Local file system plugin initialized");
×
30
        }
×
31

32
        public override void ConfigureServices(IServiceCollection services)
33
        {
1✔
34
            // Register IFileSystem if not already registered
35
            if (!services.Any(s => s.ServiceType == typeof(IFileSystem)))
1✔
36
            {
1✔
37
                services.AddSingleton<IFileSystem>(new FileSystem());
1✔
38
            }
1✔
39
        }
1✔
40

41
        public override bool FileExists(string path)
42
        {
303✔
43
            ValidatePath(path);
303✔
44
            return _fileSystem.File.Exists(path);
303✔
45
        }
303✔
46

47
        public override bool DirectoryExists(string path)
48
        {
168✔
49
            ValidatePath(path);
168✔
50
            return _fileSystem.Directory.Exists(path);
168✔
51
        }
168✔
52

53
        public override string ReadAllText(string path)
54
        {
253✔
55
            ValidatePath(path);
253✔
56
            if (!FileExists(path))
253✔
57
            {
7✔
58
                throw new FileNotFoundException($"File not found: {path}");
7✔
59
            }
60
            return _fileSystem.File.ReadAllText(path);
246✔
61
        }
246✔
62

63
        public override List<string> ReadLines(string path)
UNCOV
64
        {
×
UNCOV
65
            ValidatePath(path);
×
UNCOV
66
            if (!FileExists(path))
×
67
            {
×
68
                throw new FileNotFoundException($"File not found: {path}");
×
69
            }
UNCOV
70
            return new List<string>(_fileSystem.File.ReadAllLines(path));
×
UNCOV
71
        }
×
72

73
        public override async Task<List<string>> ReadLinesAsync(string path)
74
        {
×
75
            return await Task.Run(() => ReadLines(path));
×
76
        }
×
77

78
        public override byte[] ReadAllBytes(string path)
79
        {
13✔
80
            ValidatePath(path);
13✔
81
            if (!FileExists(path))
13!
82
            {
×
83
                throw new FileNotFoundException($"File not found: {path}");
×
84
            }
85
            return _fileSystem.File.ReadAllBytes(path);
13✔
86
        }
13✔
87

88
        public override void WriteAllText(string path, string contents)
89
        {
12✔
90
            ValidatePath(path);
12✔
91
            
92
            // Ensure directory exists
93
            string directory = GetDirectoryName(path);
12✔
94
            if (!string.IsNullOrEmpty(directory) && !DirectoryExists(directory))
12!
95
            {
2✔
96
                CreateDirectory(directory);
2✔
97
            }
2✔
98
            
99
            _fileSystem.File.WriteAllText(path, contents);
12✔
100
        }
12✔
101

102
        public override void WriteAllBytes(string path, byte[] bytes)
103
        {
9✔
104
            ValidatePath(path);
9✔
105
            if (bytes == null)
9!
106
            {
×
107
                throw new ArgumentNullException(nameof(bytes));
×
108
            }
109
            
110
            // Ensure directory exists
111
            string directory = GetDirectoryName(path);
9✔
112
            if (!string.IsNullOrEmpty(directory) && !DirectoryExists(directory))
9!
113
            {
×
114
                CreateDirectory(directory);
×
115
            }
×
116
            
117
            _fileSystem.File.WriteAllBytes(path, bytes);
9✔
118
        }
9✔
119

120
        public override Stream OpenRead(string path)
121
        {
5✔
122
            ValidatePath(path);
5✔
123
            if (!FileExists(path))
5!
124
            {
×
125
                throw new FileNotFoundException($"File not found: {path}");
×
126
            }
127
            return _fileSystem.File.OpenRead(path);
5✔
128
        }
5✔
129

130
        public override Stream OpenWrite(string path, FileMode mode = FileMode.Create)
131
        {
×
132
            ValidatePath(path);
×
133
            
134
            // Ensure directory exists
135
            string directory = GetDirectoryName(path);
×
136
            if (!string.IsNullOrEmpty(directory) && !DirectoryExists(directory))
×
137
            {
×
138
                CreateDirectory(directory);
×
139
            }
×
140
            
141
            return _fileSystem.File.Open(path, mode);
×
142
        }
×
143

144
        public override void CreateDirectory(string path)
145
        {
9✔
146
            ValidatePath(path);
9✔
147
            _fileSystem.Directory.CreateDirectory(path);
9✔
148
        }
9✔
149

150
        public override void DeleteFile(string path)
151
        {
6✔
152
            ValidatePath(path);
6✔
153
            if (!FileExists(path))
6✔
154
            {
1✔
155
                throw new FileNotFoundException($"File not found: {path}");
1✔
156
            }
157
            _fileSystem.File.Delete(path);
5✔
158
        }
5✔
159

160
        public override void DeleteDirectory(string path, bool recursive = false)
161
        {
1✔
162
            ValidatePath(path);
1✔
163
            if (!DirectoryExists(path))
1!
164
            {
×
165
                throw new DirectoryNotFoundException($"Directory not found: {path}");
×
166
            }
167
            _fileSystem.Directory.Delete(path, recursive);
1✔
168
        }
1✔
169

170
        public override string[] GetFiles(string path, string searchPattern = "*", SearchOption searchOption = SearchOption.TopDirectoryOnly)
171
        {
62✔
172
            ValidatePath(path);
62✔
173
            if (!DirectoryExists(path))
62✔
174
            {
1✔
175
                throw new DirectoryNotFoundException($"Directory not found: {path}");
1✔
176
            }
177
            return _fileSystem.Directory.GetFiles(path, searchPattern, searchOption);
61✔
178
        }
61✔
179

180
        public override string[] GetDirectories(string path, string searchPattern = "*", SearchOption searchOption = SearchOption.TopDirectoryOnly)
181
        {
×
182
            ValidatePath(path);
×
183
            if (!DirectoryExists(path))
×
184
            {
×
185
                throw new DirectoryNotFoundException($"Directory not found: {path}");
×
186
            }
187
            return _fileSystem.Directory.GetDirectories(path, searchPattern, searchOption);
×
188
        }
×
189

190
        public override void CopyFile(string sourcePath, string destinationPath, bool overwrite = false)
191
        {
4✔
192
            ValidatePath(sourcePath, "sourcePath");
4✔
193
            ValidatePath(destinationPath, "destinationPath");
4✔
194
            
195
            if (!FileExists(sourcePath))
4!
196
            {
×
197
                throw new FileNotFoundException($"Source file not found: {sourcePath}");
×
198
            }
199
            
200
            // Ensure destination directory exists
201
            string destinationDirectory = GetDirectoryName(destinationPath);
4✔
202
            if (!string.IsNullOrEmpty(destinationDirectory) && !DirectoryExists(destinationDirectory))
4!
203
            {
×
204
                CreateDirectory(destinationDirectory);
×
205
            }
×
206
            
207
            _fileSystem.File.Copy(sourcePath, destinationPath, overwrite);
4✔
208
        }
4✔
209

210
        public override void MoveFile(string sourcePath, string destinationPath, bool overwrite = false)
211
        {
×
212
            ValidatePath(sourcePath, "sourcePath");
×
213
            ValidatePath(destinationPath, "destinationPath");
×
214
            
215
            if (!FileExists(sourcePath))
×
216
            {
×
217
                throw new FileNotFoundException($"Source file not found: {sourcePath}");
×
218
            }
219
            
220
            if (FileExists(destinationPath) && !overwrite)
×
221
            {
×
222
                throw new IOException($"Destination file already exists: {destinationPath}");
×
223
            }
224
            
225
            // Ensure destination directory exists
226
            string destinationDirectory = GetDirectoryName(destinationPath);
×
227
            if (!string.IsNullOrEmpty(destinationDirectory) && !DirectoryExists(destinationDirectory))
×
228
            {
×
229
                CreateDirectory(destinationDirectory);
×
230
            }
×
231
            
232
            _fileSystem.File.Move(sourcePath, destinationPath, overwrite);
×
233
        }
×
234

235
        public override DateTime GetLastWriteTime(string path)
236
        {
×
237
            ValidatePath(path);
×
238
            if (!FileExists(path))
×
239
            {
×
240
                throw new FileNotFoundException($"File not found: {path}");
×
241
            }
242
            return _fileSystem.File.GetLastWriteTime(path);
×
243
        }
×
244

245
        public override long GetFileSize(string path)
246
        {
1✔
247
            ValidatePath(path);
1✔
248
            if (!FileExists(path))
1!
249
            {
×
250
                throw new FileNotFoundException($"File not found: {path}");
×
251
            }
252
            return _fileSystem.FileInfo.New(path).Length;
1✔
253
        }
1✔
254

255
        public override string Combine(params string[] paths)
256
        {
214✔
257
            if (paths == null || paths.Length == 0)
214!
258
            {
×
259
                throw new ArgumentException("At least one path must be provided.");
×
260
            }
261
            return _fileSystem.Path.Combine(paths);
214✔
262
        }
214✔
263

264
        public override string GetDirectoryName(string path)
265
        {
100✔
266
            ValidatePath(path);
100✔
267
            return _fileSystem.Path.GetDirectoryName(path);
100✔
268
        }
100✔
269

270
        public override string GetFileName(string path)
271
        {
21✔
272
            ValidatePath(path);
21✔
273
            return _fileSystem.Path.GetFileName(path);
21✔
274
        }
21✔
275

276
        public override string GetFileNameWithoutExtension(string path)
277
        {
×
278
            ValidatePath(path);
×
279
            return _fileSystem.Path.GetFileNameWithoutExtension(path);
×
280
        }
×
281

282
        public override string GetExtension(string path)
283
        {
13✔
284
            ValidatePath(path);
13✔
285
            return _fileSystem.Path.GetExtension(path);
13✔
286
        }
13✔
287

288
        public override string GetFullPath(string path)
289
        {
140✔
290
            ValidatePath(path);
140✔
291
            return _fileSystem.Path.GetFullPath(path);
140✔
292
        }
140✔
293

294
        public override bool IsPathRooted(string path)
295
        {
×
296
            ValidatePath(path);
×
297
            return _fileSystem.Path.IsPathRooted(path);
×
298
        }
×
299

300
        public override string GetRelativePath(string relativeTo, string path)
301
        {
4✔
302
            ValidatePath(relativeTo, "relativeTo");
4✔
303
            ValidatePath(path, "path");
4✔
304
            return _fileSystem.Path.GetRelativePath(relativeTo, path);
4✔
305
        }
4✔
306
    }
307
} 
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc