You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.1 KiB
36 lines
1.1 KiB
using System.IO.Abstractions;
|
|
using System.Reflection;
|
|
|
|
namespace Recyclarr.Common.TestLibrary;
|
|
|
|
public static class CommonMockFileSystemExtensions
|
|
{
|
|
public static void AddFileFromEmbeddedResource(
|
|
this MockFileSystem fs,
|
|
IFileInfo path,
|
|
Assembly resourceAssembly,
|
|
string embeddedResourcePath)
|
|
{
|
|
fs.AddFileFromEmbeddedResource(path.FullName, resourceAssembly, embeddedResourcePath);
|
|
}
|
|
|
|
public static void AddSameFileFromEmbeddedResource(
|
|
this MockFileSystem fs,
|
|
IFileInfo path,
|
|
Type typeInAssembly,
|
|
string resourceSubPath = "Data")
|
|
{
|
|
fs.AddFileFromEmbeddedResource(path, typeInAssembly, $"{resourceSubPath}.{path.Name}");
|
|
}
|
|
|
|
public static void AddFileFromEmbeddedResource(
|
|
this MockFileSystem fs,
|
|
IFileInfo path,
|
|
Type typeInAssembly,
|
|
string embeddedResourcePath)
|
|
{
|
|
var resourcePath = $"{typeInAssembly.Namespace}.{embeddedResourcePath}";
|
|
fs.AddFileFromEmbeddedResource(path, typeInAssembly.Assembly, resourcePath);
|
|
}
|
|
}
|