Skip to content

Commit

Permalink
feat: Add initial FileVersionInfo support (#703)
Browse files Browse the repository at this point in the history
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...*
  • Loading branch information
vbreuss authored Jan 9, 2025
1 parent 5ab1829 commit 8959969
Show file tree
Hide file tree
Showing 24 changed files with 967 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
<PackageVersion Include="System.Threading.Channels" Version="8.0.0" />
<PackageVersion Include="TestableIO.System.IO.Abstractions" Version="21.1.7" />
<PackageVersion Include="TestableIO.System.IO.Abstractions" Version="21.2.1" />
<PackageVersion Include="System.IO.Compression" Version="4.3.0" />
<PackageVersion Include="System.IO.FileSystem.AccessControl" Version="5.0.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;

namespace Testably.Abstractions.Testing.FileSystem;

internal sealed class FileVersionInfoFactoryMock
: IFileVersionInfoFactory
{
private readonly MockFileSystem _fileSystem;

internal FileVersionInfoFactoryMock(MockFileSystem fileSystem)
{
_fileSystem = fileSystem;
}

#region IFileVersionInfoFactory Members

/// <inheritdoc cref="IFileSystemEntity.FileSystem" />
public IFileSystem FileSystem
=> _fileSystem;

/// <inheritdoc cref="IFileVersionInfoFactory.GetVersionInfo(string)" />
public IFileVersionInfo GetVersionInfo(string fileName)
{
using IDisposable registration = _fileSystem.StatisticsRegistration
.FileVersionInfo.RegisterMethod(nameof(GetVersionInfo), fileName);

return FileVersionInfoMock.New(_fileSystem.Storage.GetLocation(fileName), _fileSystem);
}

#endregion
}
Loading

0 comments on commit 8959969

Please sign in to comment.