25 lines
858 B
C#
25 lines
858 B
C#
using Vanguard.Content;
|
||
using Vanguard.Rules.Cards;
|
||
|
||
namespace Vanguard.Rules.Tests;
|
||
|
||
/// <summary>Общий каталог для тестов: грузится один раз из content/sets.</summary>
|
||
public static class TestCatalog
|
||
{
|
||
private static readonly Lazy<CardCatalog> LazyCatalog = new(Load, isThreadSafe: true);
|
||
|
||
public static CardCatalog Instance => LazyCatalog.Value;
|
||
|
||
private static CardCatalog Load()
|
||
{
|
||
var dir = new DirectoryInfo(AppContext.BaseDirectory);
|
||
while (dir is not null && !Directory.Exists(Path.Combine(dir.FullName, "content", "sets")))
|
||
dir = dir.Parent;
|
||
|
||
if (dir is null)
|
||
throw new InvalidOperationException("Не найден каталог content/sets.");
|
||
|
||
return CatalogLoader.LoadDirectory(Path.Combine(dir.FullName, "content", "sets"));
|
||
}
|
||
}
|