Fixes #4374 - Nukes all (?) legacy Driver and Application stuff; revamps tests (#4376)

This commit is contained in:
Tig
2025-11-11 16:29:33 -07:00
committed by GitHub
parent 559dea9239
commit d53fcd7485
310 changed files with 14827 additions and 16911 deletions

View File

@@ -0,0 +1,45 @@
#nullable enable
using System.Diagnostics;
using System.Reflection;
using JetBrains.Annotations;
using TerminalGuiFluentTesting;
using Xunit.Sdk;
namespace UnitTests;
/// <summary>
/// Enables test functions annotated with the [SetupFakeDriver] attribute to set Application.Driver to new
/// FakeDriver(). The driver is set up with 80 rows and 25 columns.
/// </summary>
[AttributeUsage (AttributeTargets.Class | AttributeTargets.Method)]
public class SetupFakeApplicationAttribute : BeforeAfterTestAttribute
{
private IDisposable? _appDispose = null!;
public override void Before (MethodInfo methodUnderTest)
{
Debug.WriteLine ($"Before: {methodUnderTest.Name}");
_appDispose?.Dispose ();
var appFactory = new FakeApplicationFactory ();
_appDispose = appFactory.SetupFakeApplication ();
base.Before (methodUnderTest);
}
public override void After (MethodInfo methodUnderTest)
{
Debug.WriteLine ($"After: {methodUnderTest.Name}");
_appDispose?.Dispose ();
_appDispose = null;
base.After (methodUnderTest);
}
/// <summary>
/// Runs a single iteration of the main loop (layout, draw, run timed events etc.)
/// </summary>
public static void RunIteration () { ((ApplicationImpl)ApplicationImpl.Instance).Coordinator?.RunIteration (); }
}