Support unittest with Release Builds

This commit is contained in:
Charlie Kindel
2022-12-05 20:18:17 -07:00
parent a0b36d3457
commit 3307e84e3a
4 changed files with 20 additions and 8 deletions

View File

@@ -10,14 +10,13 @@
<!-- Version numbers are automatically updated by gitversion when a release is released -->
<!-- In the source tree the version will always be 1.0 for all projects. -->
<!-- Do not modify these. Do NOT commit after manually running `dotnet-gitversion /updateprojectfiles` -->
<AssemblyVersion>1.0</AssemblyVersion>
<FileVersion>1.0</FileVersion>
<Version>1.0</Version>
<InformationalVersion>1.0</InformationalVersion>
<AssemblyVersion>1.9</AssemblyVersion>
<Version>1.9</Version>
<InformationalVersion>1.9</InformationalVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
<PackageReference Include="NStack.Core" Version="1.0.5" />
<PackageReference Include="NStack.Core" Version="1.*" />
<InternalsVisibleTo Include="UnitTests" />
</ItemGroup>
<!-- Uncomment the RestoreSources element to have dotnet restore pull NStack from a local dir for testing -->

View File

@@ -75,13 +75,14 @@ namespace Terminal.Gui.Core {
// Verify state is back to initial
Pre_Init_State ();
#if DEBUG_IDISPOSABLE
// Validate there are no outstanding Responder-based instances
// after a scenario was selected to run. This proves the main UI Catalog
// 'app' closed cleanly.
foreach (var inst in Responder.Instances) {
Assert.True (inst.WasDisposed);
}
#endif
}
[Fact]
@@ -91,8 +92,10 @@ namespace Terminal.Gui.Core {
Application.Shutdown ();
#if DEBUG_IDISPOSABLE
Assert.Single (Responder.Instances);
Assert.True (Responder.Instances [0].WasDisposed);
#endif
}
[Fact]

View File

@@ -30,9 +30,11 @@ namespace Terminal.Gui.Core {
Application.Shutdown ();
#if DEBUG_IDISPOSABLE
Assert.Equal (2, Responder.Instances.Count);
Assert.True (Responder.Instances [0].WasDisposed);
Assert.True (Responder.Instances [1].WasDisposed);
#endif
}
[Fact]
@@ -45,10 +47,11 @@ namespace Terminal.Gui.Core {
Application.End (rs);
Application.Shutdown ();
#if DEBUG_IDISPOSABLE
Assert.Equal (2, Responder.Instances.Count);
Assert.True (Responder.Instances [0].WasDisposed);
Assert.True (Responder.Instances [1].WasDisposed);
#endif
}
[Fact, AutoInitShutdown]

View File

@@ -40,8 +40,9 @@ namespace Terminal.Gui.Core {
// Should not throw because Toplevel was null
rs.Dispose ();
#if DEBUG_IDISPOSABLE
Assert.True (rs.WasDisposed);
#endif
var top = new Toplevel ();
rs = new Application.RunState (top);
Assert.NotNull (rs);
@@ -52,8 +53,10 @@ namespace Terminal.Gui.Core {
rs.Toplevel.Dispose ();
rs.Toplevel = null;
rs.Dispose ();
#if DEBUG_IDISPOSABLE
Assert.True (rs.WasDisposed);
Assert.True (top.WasDisposed);
#endif
}
void Init ()
@@ -67,10 +70,12 @@ namespace Terminal.Gui.Core {
void Shutdown ()
{
Application.Shutdown ();
#if DEBUG_IDISPOSABLE
// Validate there are no outstanding RunState-based instances left
foreach (var inst in Application.RunState.Instances) {
Assert.True (inst.WasDisposed);
}
#endif
}
[Fact]
@@ -95,7 +100,9 @@ namespace Terminal.Gui.Core {
Shutdown ();
#if DEBUG_IDISPOSABLE
Assert.True (rs.WasDisposed);
#endif
Assert.Null (Application.Top);
Assert.Null (Application.MainLoop);