mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-02 01:03:29 +01:00
Started on unit test
This commit is contained in:
@@ -69,6 +69,9 @@ public class AutoInitShutdownAttribute : BeforeAfterTestAttribute
|
||||
{
|
||||
Debug.WriteLine ($"After: {methodUnderTest.Name}");
|
||||
|
||||
// Turn off diagnostic flags in case some test left them on
|
||||
View.Diagnostics = ViewDiagnosticFlags.Off;
|
||||
|
||||
if (AutoInit)
|
||||
{
|
||||
Application.Shutdown ();
|
||||
@@ -145,6 +148,10 @@ public class SetupFakeDriverAttribute : BeforeAfterTestAttribute
|
||||
public override void After (MethodInfo methodUnderTest)
|
||||
{
|
||||
Debug.WriteLine ($"After: {methodUnderTest.Name}");
|
||||
|
||||
// Turn off diagnostic flags in case some test left them on
|
||||
View.Diagnostics = ViewDiagnosticFlags.Off;
|
||||
|
||||
Application.Driver = null;
|
||||
}
|
||||
|
||||
|
||||
29
UnitTests/View/DiagnosticsTests.cs
Normal file
29
UnitTests/View/DiagnosticsTests.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
#nullable enable
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Terminal.Gui.ViewTests;
|
||||
|
||||
/// <summary>
|
||||
/// Tests <see cref="View.Diagnostics"/> static property and <see cref="ViewDiagnosticFlags"/> enum.
|
||||
/// </summary>
|
||||
/// <param name="output"></param>
|
||||
[Trait("Category","Output")]
|
||||
public class DiagnosticTests (ITestOutputHelper output)
|
||||
{
|
||||
/// <summary>
|
||||
/// /// Tests <see cref="View.Diagnostics"/> static property and <see cref="ViewDiagnosticFlags"/> enum.
|
||||
/// /// </summary>
|
||||
[Fact]
|
||||
public void Diagnostics_Sets ()
|
||||
{
|
||||
// View.Diagnostics is a static property that returns the current diagnostic flags.
|
||||
Assert.Equal (ViewDiagnosticFlags.Off, View.Diagnostics);
|
||||
|
||||
// View.Diagnostics can be set to a new value.
|
||||
View.Diagnostics = ViewDiagnosticFlags.Padding;
|
||||
Assert.Equal (ViewDiagnosticFlags.Padding, View.Diagnostics);
|
||||
|
||||
// Ensure we turn off at the end of the test
|
||||
View.Diagnostics = ViewDiagnosticFlags.Off;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user