- Shared SQLite plumbing: PRAGMAs (WAL/NORMAL/foreign_keys) and user_version migrations with typed SchemaVersionException - Workspace folder: .ykanban initialization, empty schema with DDL-level constraints, preset column seeding (ResX-driven), exclusive lock file with holder diagnostics - AppData folder: app.db workspace registry (injectable clock), app.json config store with kebab-case JSON names via explicit [JsonProperty]/[EnumMember], nested sections, corrupt-file backup - ResX infrastructure under Assets/Locales (en + zh-Hans) with MSBuild strongly-typed public Resources class - 54 unit tests: DDL constraints, migrations, PRAGMAs, lock exclusivity, config degradation, culture-aware presets
32 lines
910 B
C#
32 lines
910 B
C#
namespace YKanBan.Tests.TestUtilities;
|
|
|
|
/// <summary>
|
|
/// Creates a unique temporary directory per test instance and removes it on
|
|
/// disposal. Retries the deletion once because SQLite WAL files can linger
|
|
/// for a moment after connections close.
|
|
/// </summary>
|
|
public sealed class TempDirectory : IDisposable
|
|
{
|
|
/// <summary>Unique directory path managed by this instance.</summary>
|
|
public string FullPath { get; }
|
|
|
|
public TempDirectory()
|
|
{
|
|
FullPath = Path.Combine(Path.GetTempPath(), "ykanban-tests-" + Guid.NewGuid().ToString("N"));
|
|
Directory.CreateDirectory(FullPath);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
try
|
|
{
|
|
Directory.Delete(FullPath, recursive: true);
|
|
}
|
|
catch (IOException)
|
|
{
|
|
Thread.Sleep(100);
|
|
try { Directory.Delete(FullPath, recursive: true); } catch (IOException) { }
|
|
}
|
|
}
|
|
}
|