forked from TestableIO/System.IO.Abstractions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMockFileVersionInfoFactory.cs
More file actions
33 lines (28 loc) · 962 Bytes
/
MockFileVersionInfoFactory.cs
File metadata and controls
33 lines (28 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
namespace System.IO.Abstractions.TestingHelpers
{
/// <inheritdoc />
#if FEATURE_SERIALIZABLE
[Serializable]
#endif
public class MockFileVersionInfoFactory : IFileVersionInfoFactory
{
private readonly IMockFileDataAccessor mockFileSystem;
/// <inheritdoc />
public MockFileVersionInfoFactory(IMockFileDataAccessor mockFileSystem)
{
this.mockFileSystem = mockFileSystem ?? throw new ArgumentNullException(nameof(mockFileSystem));
}
/// <inheritdoc />
public IFileSystem FileSystem => mockFileSystem;
/// <inheritdoc />
public IFileVersionInfo GetVersionInfo(string fileName)
{
MockFileData mockFileData = mockFileSystem.GetFile(fileName);
if (mockFileData != null)
{
return mockFileData.FileVersionInfo;
}
throw CommonExceptions.FileNotFound(fileName);
}
}
}