mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-30 01:38:01 +01:00
Fix fence logic to work with parallel tests
Co-authored-by: tig <585482+tig@users.noreply.github.com>
This commit is contained in:
@@ -18,11 +18,12 @@ public class ApplicationModelFencingTests
|
||||
{
|
||||
// Create a modern instance-based application
|
||||
IApplication app = Application.Create ();
|
||||
app.Init ("fake");
|
||||
|
||||
// Attempting to access the legacy static instance should throw
|
||||
// Attempting to initialize using the legacy static model should throw
|
||||
InvalidOperationException ex = Assert.Throws<InvalidOperationException> (() =>
|
||||
{
|
||||
IApplication _ = ApplicationImpl.Instance;
|
||||
ApplicationImpl.Instance.Init ("fake");
|
||||
});
|
||||
|
||||
Assert.Contains ("Cannot use legacy static Application model", ex.Message);
|
||||
@@ -35,13 +36,15 @@ public class ApplicationModelFencingTests
|
||||
[Fact]
|
||||
public void InstanceAccess_ThenCreate_ThrowsInvalidOperationException ()
|
||||
{
|
||||
// Access the legacy static instance
|
||||
// Initialize using the legacy static model
|
||||
IApplication staticInstance = ApplicationImpl.Instance;
|
||||
staticInstance.Init ("fake");
|
||||
|
||||
// Attempting to create a modern instance-based application should throw
|
||||
// Attempting to create and initialize with modern instance-based model should throw
|
||||
InvalidOperationException ex = Assert.Throws<InvalidOperationException> (() =>
|
||||
{
|
||||
IApplication _ = Application.Create ();
|
||||
IApplication app = Application.Create ();
|
||||
app.Init ("fake");
|
||||
});
|
||||
|
||||
Assert.Contains ("Cannot use modern instance-based model", ex.Message);
|
||||
@@ -78,11 +81,10 @@ public class ApplicationModelFencingTests
|
||||
IApplication app = Application.Create ();
|
||||
app.Init ("fake");
|
||||
|
||||
// Attempting to access the legacy static instance should throw
|
||||
// (Init calls ApplicationImpl.Instance internally)
|
||||
// Attempting to initialize using the legacy static model should throw
|
||||
InvalidOperationException ex = Assert.Throws<InvalidOperationException> (() =>
|
||||
{
|
||||
IApplication _ = ApplicationImpl.Instance;
|
||||
ApplicationImpl.Instance.Init ("fake");
|
||||
});
|
||||
|
||||
Assert.Contains ("Cannot use legacy static Application model", ex.Message);
|
||||
|
||||
Reference in New Issue
Block a user