|
@@ -46,6 +46,32 @@ public class ApplicationTests
|
|
|
Assert.Equal (new Rectangle (0, 0, 5, 5), Application.Top.Frame);
|
|
|
}
|
|
|
|
|
|
+ [Fact]
|
|
|
+ public void End_Should_Not_Dispose_ApplicationTop_Shutdown_Should ()
|
|
|
+ {
|
|
|
+ Init ();
|
|
|
+
|
|
|
+ RunState rs = Application.Begin (Application.Top);
|
|
|
+ Application.End (rs);
|
|
|
+
|
|
|
+#if DEBUG_IDISPOSABLE
|
|
|
+ Assert.True (rs.WasDisposed);
|
|
|
+ Assert.False (Application.Top.WasDisposed);
|
|
|
+#endif
|
|
|
+
|
|
|
+ Assert.Null (rs.Toplevel);
|
|
|
+
|
|
|
+ var top = Application.Top;
|
|
|
+
|
|
|
+ Shutdown ();
|
|
|
+
|
|
|
+#if DEBUG_IDISPOSABLE
|
|
|
+ Assert.True (top.WasDisposed);
|
|
|
+#endif
|
|
|
+
|
|
|
+ Assert.Null (Application.Top);
|
|
|
+ }
|
|
|
+
|
|
|
[Fact]
|
|
|
public void Init_Begin_End_Cleans_Up ()
|
|
|
{
|
|
@@ -470,12 +496,13 @@ public class ApplicationTests
|
|
|
#region RunTests
|
|
|
|
|
|
[Fact]
|
|
|
+
|
|
|
public void Run_T_After_InitWithDriver_with_TopLevel_Throws ()
|
|
|
{
|
|
|
// Setup Mock driver
|
|
|
Init ();
|
|
|
|
|
|
- // Run<Toplevel> when already initialized with a Driver will throw (because Toplevel is not dervied from TopLevel)
|
|
|
+ // Run<Toplevel> when already initialized with a Driver will throw (because Toplevel is not derived from TopLevel)
|
|
|
Assert.Throws<ArgumentException> (() => Application.Run<Toplevel> ());
|
|
|
|
|
|
Shutdown ();
|
|
@@ -486,12 +513,13 @@ public class ApplicationTests
|
|
|
}
|
|
|
|
|
|
[Fact]
|
|
|
+
|
|
|
public void Run_T_After_InitWithDriver_with_TopLevel_and_Driver_Throws ()
|
|
|
{
|
|
|
// Setup Mock driver
|
|
|
Init ();
|
|
|
|
|
|
- // Run<Toplevel> when already initialized with a Driver will throw (because Toplevel is not dervied from TopLevel)
|
|
|
+ // Run<Toplevel> when already initialized with a Driver will throw (because Toplevel is not derivied from TopLevel)
|
|
|
Assert.Throws<ArgumentException> (() => Application.Run<Toplevel> (null, new FakeDriver ()));
|
|
|
|
|
|
Shutdown ();
|
|
@@ -502,6 +530,40 @@ public class ApplicationTests
|
|
|
}
|
|
|
|
|
|
[Fact]
|
|
|
+ [TestRespondersDisposed]
|
|
|
+
|
|
|
+ public void Run_T_After_Init_Disposes_Application_Top ()
|
|
|
+ {
|
|
|
+ Init ();
|
|
|
+
|
|
|
+ // Init created a Toplevel and assigned it to Application.Top
|
|
|
+ var initTop = Application.Top;
|
|
|
+
|
|
|
+ Application.Iteration += (s, a) =>
|
|
|
+ {
|
|
|
+ Assert.NotEqual(initTop, Application.Top);
|
|
|
+#if DEBUG_IDISPOSABLE
|
|
|
+ Assert.True (initTop.WasDisposed);
|
|
|
+#endif
|
|
|
+ Application.RequestStop ();
|
|
|
+ };
|
|
|
+
|
|
|
+ Application.Run<TestToplevel> ();
|
|
|
+
|
|
|
+#if DEBUG_IDISPOSABLE
|
|
|
+ Assert.True (initTop.WasDisposed);
|
|
|
+#endif
|
|
|
+
|
|
|
+ Shutdown ();
|
|
|
+
|
|
|
+ Assert.Null (Application.Top);
|
|
|
+ Assert.Null (Application.MainLoop);
|
|
|
+ Assert.Null (Application.Driver);
|
|
|
+ }
|
|
|
+
|
|
|
+ [Fact]
|
|
|
+ [TestRespondersDisposed]
|
|
|
+
|
|
|
public void Run_T_After_InitWithDriver_with_TestTopLevel_DoesNotThrow ()
|
|
|
{
|
|
|
// Setup Mock driver
|
|
@@ -520,7 +582,9 @@ public class ApplicationTests
|
|
|
}
|
|
|
|
|
|
[Fact]
|
|
|
- public void Run_T_After_InitNullDriver_with_TestTopLevel_Throws ()
|
|
|
+ [TestRespondersDisposed]
|
|
|
+
|
|
|
+ public void Run_T_After_InitNullDriver_with_TestTopLevel_DoesNotThrow ()
|
|
|
{
|
|
|
Application.ForceDriver = "FakeDriver";
|
|
|
|
|
@@ -529,7 +593,7 @@ public class ApplicationTests
|
|
|
|
|
|
Application.Iteration += (s, a) => { Application.RequestStop (); };
|
|
|
|
|
|
- // Init has been called without selecting a driver and we're passing no driver to Run<TestTopLevel>. Bad
|
|
|
+ // Init has been called, selecting FakeDriver; we're passing no driver to Run<TestTopLevel>. Should be fine.
|
|
|
Application.Run<TestToplevel> ();
|
|
|
|
|
|
Shutdown ();
|
|
@@ -540,6 +604,8 @@ public class ApplicationTests
|
|
|
}
|
|
|
|
|
|
[Fact]
|
|
|
+ [TestRespondersDisposed]
|
|
|
+
|
|
|
public void Run_T_Init_Driver_Cleared_with_TestTopLevel_Throws ()
|
|
|
{
|
|
|
Init ();
|
|
@@ -559,6 +625,7 @@ public class ApplicationTests
|
|
|
}
|
|
|
|
|
|
[Fact]
|
|
|
+ [TestRespondersDisposed]
|
|
|
public void Run_T_NoInit_DoesNotThrow ()
|
|
|
{
|
|
|
Application.ForceDriver = "FakeDriver";
|
|
@@ -576,6 +643,8 @@ public class ApplicationTests
|
|
|
}
|
|
|
|
|
|
[Fact]
|
|
|
+ [TestRespondersDisposed]
|
|
|
+
|
|
|
public void Run_T_NoInit_WithDriver_DoesNotThrow ()
|
|
|
{
|
|
|
Application.Iteration += (s, a) => { Application.RequestStop (); };
|
|
@@ -591,6 +660,8 @@ public class ApplicationTests
|
|
|
}
|
|
|
|
|
|
[Fact]
|
|
|
+ [TestRespondersDisposed]
|
|
|
+
|
|
|
public void Run_RequestStop_Stops ()
|
|
|
{
|
|
|
// Setup Mock driver
|
|
@@ -613,6 +684,8 @@ public class ApplicationTests
|
|
|
}
|
|
|
|
|
|
[Fact]
|
|
|
+ [TestRespondersDisposed]
|
|
|
+
|
|
|
public void Run_RunningFalse_Stops ()
|
|
|
{
|
|
|
// Setup Mock driver
|
|
@@ -635,6 +708,8 @@ public class ApplicationTests
|
|
|
}
|
|
|
|
|
|
[Fact]
|
|
|
+ [TestRespondersDisposed]
|
|
|
+
|
|
|
public void Run_Loaded_Ready_Unlodaded_Events ()
|
|
|
{
|
|
|
Init ();
|
|
@@ -678,7 +753,7 @@ public class ApplicationTests
|
|
|
Application.OnMouseEvent (
|
|
|
new MouseEventEventArgs (
|
|
|
new MouseEvent
|
|
|
- { X = 0, Y = 0, Flags = MouseFlags.ReportMousePosition }
|
|
|
+ { X = 0, Y = 0, Flags = MouseFlags.ReportMousePosition }
|
|
|
)
|
|
|
);
|
|
|
Assert.False (top.NeedsDisplay);
|