Files
Terminal.Gui/Tests/UnitTests/Application/ApplicationForceDriverTests.cs
Tig 713efcc2f4 WIP: Fixed Parallel tests; non-Parallel still broken
Refactor application model usage tracking

Refactored `ApplicationModelUsage` into a public enum in the new `Terminal.Gui.App` namespace, making it accessible across the codebase. Replaced the private `_modelUsage` field in `ApplicationImpl` with a public static `ModelUsage` property to improve clarity and accessibility.

Renamed error message constants for consistency and updated methods like `SetInstance` and `MarkInstanceBasedModelUsed` to use the new `ModelUsage` property. Removed the private `ApplicationModelUsage` enum from `ApplicationImpl`.

Updated test cases to use `ApplicationImpl.Instance` instead of `Application.Create` to enforce the legacy static model. Skipped obsolete tests in `ApplicationForceDriverTests` and added null checks in `DriverAssert` and `SelectorBase` to handle edge cases.

Commented out an unused line in `WindowsOutput` and made general improvements to code readability, maintainability, and consistency.
2025-11-22 21:29:44 -07:00

42 lines
1.4 KiB
C#

using UnitTests;
namespace UnitTests.ApplicationTests;
public class ApplicationForceDriverTests : FakeDriverBase
{
[Fact (Skip = "Bogus test now that config properties are handled correctly")]
public void ForceDriver_Does_Not_Changes_If_It_Has_Valid_Value ()
{
Assert.False (Application.Initialized);
Assert.Null (Application.Driver);
Assert.Equal (string.Empty, Application.ForceDriver);
Application.ForceDriver = "fake";
Assert.Equal ("fake", Application.ForceDriver);
Application.ForceDriver = "dotnet";
Assert.Equal ("fake", Application.ForceDriver);
}
[Fact (Skip = "Bogus test now that config properties are handled correctly")]
public void ForceDriver_Throws_If_Initialized_Changed_To_Another_Value ()
{
IDriver driver = CreateFakeDriver ();
Assert.False (Application.Initialized);
Assert.Null (Application.Driver);
Assert.Equal (string.Empty, Application.ForceDriver);
Application.Init (driverName: "fake");
Assert.True (Application.Initialized);
Assert.NotNull (Application.Driver);
Assert.Equal ("fake", Application.Driver.GetName ());
Assert.Equal (string.Empty, Application.ForceDriver);
Assert.Throws<InvalidOperationException> (() => Application.ForceDriver = "dotnet");
Application.ForceDriver = "fake";
Assert.Equal ("fake", Application.ForceDriver);
}
}