From 99e33feae427347d4d775eb74f8f38d281fb5e55 Mon Sep 17 00:00:00 2001 From: usr <81042605+a-usr@users.noreply.github.com> Date: Thu, 26 Oct 2023 17:06:39 +0200 Subject: [PATCH 1/3] Update ViewDisposalTest.cs --- UnitTests/Views/ViewDisposalTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnitTests/Views/ViewDisposalTest.cs b/UnitTests/Views/ViewDisposalTest.cs index 144b73b6d..180f4712c 100644 --- a/UnitTests/Views/ViewDisposalTest.cs +++ b/UnitTests/Views/ViewDisposalTest.cs @@ -41,7 +41,7 @@ namespace UnitTests.ViewsTests { } void getSpecialParams () { - //special_params.Clear (); + special_params.Clear (); //special_params.Add (typeof (LineView), new object [] { Orientation.Horizontal }); } WeakReference DoTest () From 6f53aa480ee58eb29912be45a1d062209142b7f3 Mon Sep 17 00:00:00 2001 From: Brian Juul Andersen Date: Mon, 30 Oct 2023 16:00:20 +0100 Subject: [PATCH 2/3] Update keyboard.md (#2937) FIX minor grammatical error --- docfx/articles/keyboard.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docfx/articles/keyboard.md b/docfx/articles/keyboard.md index 9fe3b0ee4..b15a3d7d4 100644 --- a/docfx/articles/keyboard.md +++ b/docfx/articles/keyboard.md @@ -17,7 +17,7 @@ Keyboard events are sent by the [Main Loop](mainloop.md) to the Application class for processing. The keyboard events are sent exclusively to the current `Toplevel`, this being either the default that is created when you call `Application.Init`, or one that you -created an passed to `Application.Run(Toplevel)`. +created and passed to `Application.Run(Toplevel)`. Flow ---- From bb798373b50f45c9ac8f26d7e144a4ef14616d68 Mon Sep 17 00:00:00 2001 From: usr <81042605+a-usr@users.noreply.github.com> Date: Mon, 30 Oct 2023 18:34:27 +0100 Subject: [PATCH 3/3] Update ViewDisposalTest.cs: Some Formatting, and adding code comments. --- UnitTests/Views/ViewDisposalTest.cs | 38 +++++++++++++++++------------ 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/UnitTests/Views/ViewDisposalTest.cs b/UnitTests/Views/ViewDisposalTest.cs index 180f4712c..9ed8981d0 100644 --- a/UnitTests/Views/ViewDisposalTest.cs +++ b/UnitTests/Views/ViewDisposalTest.cs @@ -1,29 +1,28 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; -using System.Text; using System.Reflection; using Terminal.Gui; using Xunit; -using Console = Terminal.Gui.FakeConsole; -using Xunit.Sdk; -using Microsoft.VisualStudio.TestPlatform.Utilities; using Xunit.Abstractions; -using System.Threading; -using Terminal.Gui.Graphs; namespace UnitTests.ViewsTests { + public class ViewDisposalTest { - ITestOutputHelper output; + +#nullable enable + Dictionary special_params = new Dictionary (); +#nullable restore + + readonly ITestOutputHelper output; + public ViewDisposalTest (ITestOutputHelper output) { { this.output = output; } } -#nullable enable - Dictionary special_params = new Dictionary (); -#nullable restore + [Fact] [AutoInitShutdown] public void TestViewsDisposeCorrectly () @@ -39,11 +38,13 @@ namespace UnitTests.ViewsTests { Assert.Fail ($"Some Views didnt get Garbage Collected: {((View)reference.Target).Subviews}"); } } + void getSpecialParams () { special_params.Clear (); //special_params.Add (typeof (LineView), new object [] { Orientation.Horizontal }); } + WeakReference DoTest () { getSpecialParams (); @@ -55,9 +56,10 @@ namespace UnitTests.ViewsTests { //Create instance of view and add to container if (special_params.ContainsKey (view)) { instance = (View)Activator.CreateInstance (view, special_params [view]); - } - else + } else { instance = (View)Activator.CreateInstance (view); + } + Assert.NotNull (instance); Container.Add (instance); output.WriteLine ($"Added instance of {view}!"); @@ -67,6 +69,7 @@ namespace UnitTests.ViewsTests { for (var i = 0; i < 100; i++) { Application.Refresh (); } + top.Remove (Container); WeakReference reference = new (Container, true); Container.Dispose (); @@ -81,14 +84,17 @@ namespace UnitTests.ViewsTests { { List valid = new (); // Filter all types that can be instantiated, are public, arent generic, aren't the view type itself, but derive from view - foreach (var type in Assembly.GetAssembly (typeof (View)).GetTypes ().Where (T => { - return ((!T.IsAbstract) && T.IsPublic && T.IsClass && T.IsAssignableTo (typeof (View)) && !T.IsGenericType && !(T == typeof (View)));})) { + foreach (var type in Assembly.GetAssembly (typeof (View)).GetTypes ().Where (T => { //body of anonymous check function + return ((!T.IsAbstract) && T.IsPublic && T.IsClass && T.IsAssignableTo (typeof (View)) && !T.IsGenericType && !(T == typeof (View))); + })) //end of body of anonymous check function + { //body of the foreach loop output.WriteLine ($"Found Type {type.Name}"); Assert.DoesNotContain (type, valid); Assert.True (type.IsAssignableTo (typeof (IDisposable)));// Just to be safe valid.Add (type); output.WriteLine (" -Added!"); - } + } //end body of foreach loop + return valid; } }