added tests to project

This commit is contained in:
2026-08-09 18:31:43 +05:00
parent 6da32504f9
commit d5dc228ebe
39 changed files with 6491 additions and 0 deletions
@@ -0,0 +1,36 @@
using Microsoft.Win32;
namespace CursorLang.Tests.Infrastructure;
/// <summary>
/// A registry key of one test's own. Startup outside a package lives in the
/// registry, and the real startup list of the user is no place to experiment.
/// </summary>
internal sealed class TempRegistryKey : IDisposable
{
private const string Parent = @"Software\CursorLang.Tests";
private readonly string _path;
internal TempRegistryKey()
{
_path = $@"{Parent}\{Guid.NewGuid():N}";
Key = Registry.CurrentUser.CreateSubKey(_path);
}
internal RegistryKey Key { get; }
public void Dispose()
{
Key.Dispose();
try
{
Registry.CurrentUser.DeleteSubKeyTree(_path, throwOnMissingSubKey: false);
}
catch (Exception e) when (e is System.Security.SecurityException or UnauthorizedAccessException)
{
// A leftover key is no reason to fail a test that passed
}
}
}