فهرست منبع

Fix ApplicationImplBeginEndTests: Remove explicit ResetState calls, rely on Shutdown

Per maintainer feedback:
- Tests should not call ResetState explicitly if they call Shutdown (Shutdown calls ResetState)
- Removed all explicit app.ResetState() calls from tests
- Tests now only call Shutdown in finally blocks for cleanup
- Ensured toplevels are disposed BEFORE Shutdown to satisfy DEBUG_IDISPOSABLE assertions
- Fixed test cleanup order to prevent ResetState assertion failures
- All 16 tests now pass successfully

ResetState is idempotent - the issue was tests calling it unnecessarily and with incorrect disposal ordering.

Co-authored-by: tig <[email protected]>
copilot-swe-agent[bot] 4 هفته پیش
والد
کامیت
429bfbf790
1فایلهای تغییر یافته به همراه21 افزوده شده و 14 حذف شده
  1. 21 14
      Tests/UnitTests/Application/ApplicationImplBeginEndTests.cs

+ 21 - 14
Tests/UnitTests/Application/ApplicationImplBeginEndTests.cs

@@ -194,16 +194,19 @@ public class ApplicationImplBeginEndTests
             SessionToken token2 = app.Begin (toplevel2);
             
             // Trying to end token1 when token2 is on top should throw
+            // NOTE: This throws but has the side effect of popping token2 from the stack
             Assert.Throws<ArgumentException> (() => app.End (token1));
             
-            // Cleanup
-            app.End (token2);
-            app.End (token1);
+            // Don't try to clean up with more End calls - the state is now inconsistent
+            // Let Shutdown/ResetState handle cleanup
         }
         finally
         {
+            // Dispose toplevels BEFORE Shutdown to satisfy DEBUG_IDISPOSABLE assertions
             toplevel1?.Dispose ();
             toplevel2?.Dispose ();
+            
+            // Shutdown will call ResetState which clears any remaining state
             app.Shutdown ();
         }
     }
@@ -357,18 +360,20 @@ public class ApplicationImplBeginEndTests
             
             Assert.Equal (2, app.SessionStack.Count);
             Assert.NotNull (app.Current);
-            
-            app.ResetState ();
-            
-            Assert.Empty (app.SessionStack);
-            Assert.Null (app.Current);
-            Assert.Null (app.CachedSessionTokenToplevel);
         }
         finally
         {
+            // Dispose toplevels BEFORE Shutdown to satisfy DEBUG_IDISPOSABLE assertions
             toplevel1?.Dispose ();
             toplevel2?.Dispose ();
+            
+            // Shutdown calls ResetState, which will clear SessionStack and set Current to null
             app.Shutdown ();
+            
+            // Verify cleanup happened
+            Assert.Empty (app.SessionStack);
+            Assert.Null (app.Current);
+            Assert.Null (app.CachedSessionTokenToplevel);
         }
     }
 
@@ -389,17 +394,19 @@ public class ApplicationImplBeginEndTests
             
             Assert.True (toplevel1.Running);
             Assert.True (toplevel2.Running);
-            
-            app.ResetState ();
-            
-            Assert.False (toplevel1.Running);
-            Assert.False (toplevel2.Running);
         }
         finally
         {
+            // Dispose toplevels BEFORE Shutdown to satisfy DEBUG_IDISPOSABLE assertions
             toplevel1?.Dispose ();
             toplevel2?.Dispose ();
+            
+            // Shutdown calls ResetState, which will stop all running toplevels
             app.Shutdown ();
+            
+            // Verify toplevels were stopped
+            Assert.False (toplevel1!.Running);
+            Assert.False (toplevel2!.Running);
         }
     }