Skip to content

Commit 8959969

Browse files
authored
feat: Add initial FileVersionInfo support (#703)
Support for `FileVersionInfo` was added in TestableIO/System.IO.Abstractions#1177. Add basic support for the updated interfaces. *It is not yet possible to influence the mocked `IFileVersionInfo` in any way...*
1 parent 5ab1829 commit 8959969

24 files changed

+967
-1
lines changed

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
77
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
88
<PackageVersion Include="System.Threading.Channels" Version="8.0.0" />
9-
<PackageVersion Include="TestableIO.System.IO.Abstractions" Version="21.1.7" />
9+
<PackageVersion Include="TestableIO.System.IO.Abstractions" Version="21.2.1" />
1010
<PackageVersion Include="System.IO.Compression" Version="4.3.0" />
1111
<PackageVersion Include="System.IO.FileSystem.AccessControl" Version="5.0.0" />
1212
</ItemGroup>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
3+
namespace Testably.Abstractions.Testing.FileSystem;
4+
5+
internal sealed class FileVersionInfoFactoryMock
6+
: IFileVersionInfoFactory
7+
{
8+
private readonly MockFileSystem _fileSystem;
9+
10+
internal FileVersionInfoFactoryMock(MockFileSystem fileSystem)
11+
{
12+
_fileSystem = fileSystem;
13+
}
14+
15+
#region IFileVersionInfoFactory Members
16+
17+
/// <inheritdoc cref="IFileSystemEntity.FileSystem" />
18+
public IFileSystem FileSystem
19+
=> _fileSystem;
20+
21+
/// <inheritdoc cref="IFileVersionInfoFactory.GetVersionInfo(string)" />
22+
public IFileVersionInfo GetVersionInfo(string fileName)
23+
{
24+
using IDisposable registration = _fileSystem.StatisticsRegistration
25+
.FileVersionInfo.RegisterMethod(nameof(GetVersionInfo), fileName);
26+
27+
return FileVersionInfoMock.New(_fileSystem.Storage.GetLocation(fileName), _fileSystem);
28+
}
29+
30+
#endregion
31+
}

0 commit comments

Comments
 (0)