VanguardReMaster/server/tests/Vanguard.Rules.Tests/TestCatalog.cs

25 lines
858 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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"));
}
}