Browse Source

Removed unused API and cleaned up code

Tig Kindel 1 year ago
parent
commit
748cdfd803
2 changed files with 296 additions and 338 deletions
  1. 140 182
      Terminal.Gui/Views/ToplevelOverlapped.cs
  2. 156 156
      UnitTests/Views/ToplevelTests.cs

+ 140 - 182
Terminal.Gui/Views/ToplevelOverlapped.cs

@@ -1,226 +1,184 @@
 using System;
 using System.Collections.Generic;
-using System.ComponentModel;
 using System.Linq;
 
-namespace Terminal.Gui {
-	public partial class Toplevel {
-		/// <summary>
-		/// Gets or sets if this Toplevel is a container for overlapped children.
-		/// </summary>
-		public bool IsOverlappedContainer { get; set; }
-
-		/// <summary>
-		/// Gets or sets if this Toplevel is in overlapped mode within a Toplevel container.
-		/// </summary>
-		public bool IsOverlapped {
-			get {
-				return Application.OverlappedTop != null && Application.OverlappedTop != this && !Modal;
-			}
-		}
+namespace Terminal.Gui; 
 
-	}
+public partial class Toplevel {
+	/// <summary>
+	/// Gets or sets if this Toplevel is a container for overlapped children.
+	/// </summary>
+	public bool IsOverlappedContainer { get; set; }
+
+	/// <summary>
+	/// Gets or sets if this Toplevel is in overlapped mode within a Toplevel container.
+	/// </summary>
+	public bool IsOverlapped => Application.OverlappedTop != null && Application.OverlappedTop != this && !Modal;
+}
 
-	public static partial class Application {
-
-		/// <summary>
-		/// Gets the list of the Overlapped children which are not modal <see cref="Toplevel"/> from the <see cref="OverlappedTop"/>.
-		/// </summary>
-		public static List<Toplevel> OverlappedChildren {
-			get {
-				if (OverlappedTop != null) {
-					List<Toplevel> _overlappedChildren = new List<Toplevel> ();
-					foreach (var top in _topLevels) {
-						if (top != OverlappedTop && !top.Modal) {
-							_overlappedChildren.Add (top);
-						}
+public static partial class Application {
+	/// <summary>
+	/// Gets the list of the Overlapped children which are not modal <see cref="Toplevel"/> from the
+	/// <see cref="OverlappedTop"/>.
+	/// </summary>
+	public static List<Toplevel> OverlappedChildren {
+		get {
+			if (OverlappedTop != null) {
+				var _overlappedChildren = new List<Toplevel> ();
+				foreach (var top in _topLevels) {
+					if (top != OverlappedTop && !top.Modal) {
+						_overlappedChildren.Add (top);
 					}
-					return _overlappedChildren;
 				}
-				return null;
+				return _overlappedChildren;
 			}
+			return null;
 		}
+	}
 
-		/// <summary>
-		/// The <see cref="Toplevel"/> object used for the application on startup which <see cref="Toplevel.IsOverlappedContainer"/> is true.
-		/// </summary>
-		public static Toplevel OverlappedTop {
-			get {
-				if (Top.IsOverlappedContainer) {
-					return Top;
-				}
-				return null;
+	/// <summary>
+	/// The <see cref="Toplevel"/> object used for the application on startup which
+	/// <see cref="Toplevel.IsOverlappedContainer"/> is true.
+	/// </summary>
+	public static Toplevel OverlappedTop {
+		get {
+			if (Top.IsOverlappedContainer) {
+				return Top;
 			}
+			return null;
 		}
+	}
 
-
-		static View FindDeepestOverlappedView (View start, int x, int y, out int resx, out int resy)
-		{
-			if (start.GetType ().BaseType != typeof (Toplevel)
-				&& !((Toplevel)start).IsOverlappedContainer) {
-				resx = 0;
-				resy = 0;
-				return null;
-			}
-
-			var startFrame = start.Frame;
-
-			if (!startFrame.Contains (x, y)) {
-				resx = 0;
-				resy = 0;
-				return null;
-			}
-
-			int count = _topLevels.Count;
-			for (int i = count - 1; i >= 0; i--) {
-				foreach (var top in _topLevels) {
-					var rx = x - startFrame.X;
-					var ry = y - startFrame.Y;
-					if (top.Visible && top.Frame.Contains (rx, ry)) {
-						var deep = View.FindDeepestView (top, rx, ry, out resx, out resy);
-						if (deep == null)
-							return FindDeepestOverlappedView (top, rx, ry, out resx, out resy);
-						if (deep != OverlappedTop)
-							return deep;
-					}
-				}
-			}
-			resx = x - startFrame.X;
-			resy = y - startFrame.Y;
-			return start;
+	static bool OverlappedChildNeedsDisplay ()
+	{
+		if (OverlappedTop == null) {
+			return false;
 		}
 
-		static bool OverlappedChildNeedsDisplay ()
-		{
-			if (OverlappedTop == null) {
-				return false;
-			}
-
-			foreach (var top in _topLevels) {
-				if (top != Current && top.Visible && (top.NeedsDisplay || top.SubViewNeedsDisplay || top.LayoutNeeded)) {
-					OverlappedTop.SetSubViewNeedsDisplay ();
-					return true;
-				}
+		foreach (var top in _topLevels) {
+			if (top != Current && top.Visible && (top.NeedsDisplay || top.SubViewNeedsDisplay || top.LayoutNeeded)) {
+				OverlappedTop.SetSubViewNeedsDisplay ();
+				return true;
 			}
-			return false;
 		}
+		return false;
+	}
 
 
-		static bool SetCurrentOverlappedAsTop ()
-		{
-			if (OverlappedTop == null && Current != Top && Current?.SuperView == null && Current?.Modal == false) {
-				if (Current.Frame != new Rect (0, 0, Driver.Cols, Driver.Rows)) {
-					Current.Frame = new Rect (0, 0, Driver.Cols, Driver.Rows);
-				}
-				Top = Current;
-				return true;
+	static bool SetCurrentOverlappedAsTop ()
+	{
+		if (OverlappedTop == null && Current != Top && Current?.SuperView == null && Current?.Modal == false) {
+			if (Current.Frame != new Rect (0, 0, Driver.Cols, Driver.Rows)) {
+				// BUGBUG: Use Dim.Fill
+				Current.Frame = new Rect (0, 0, Driver.Cols, Driver.Rows);
 			}
-			return false;
+			Top = Current;
+			return true;
 		}
+		return false;
+	}
 
-		/// <summary>
-		/// Move to the next Overlapped child from the <see cref="OverlappedTop"/>.
-		/// </summary>
-		public static void OverlappedMoveNext ()
-		{
-			if (OverlappedTop != null && !Current.Modal) {
-				lock (_topLevels) {
-					_topLevels.MoveNext ();
-					var isOverlapped = false;
-					while (_topLevels.Peek () == OverlappedTop || !_topLevels.Peek ().Visible) {
-						if (!isOverlapped && _topLevels.Peek () == OverlappedTop) {
-							isOverlapped = true;
-						} else if (isOverlapped && _topLevels.Peek () == OverlappedTop) {
-							MoveCurrent (Top);
-							break;
-						}
-						_topLevels.MoveNext ();
+	/// <summary>
+	/// Move to the next Overlapped child from the <see cref="OverlappedTop"/>.
+	/// </summary>
+	public static void OverlappedMoveNext ()
+	{
+		if (OverlappedTop != null && !Current.Modal) {
+			lock (_topLevels) {
+				_topLevels.MoveNext ();
+				var isOverlapped = false;
+				while (_topLevels.Peek () == OverlappedTop || !_topLevels.Peek ().Visible) {
+					if (!isOverlapped && _topLevels.Peek () == OverlappedTop) {
+						isOverlapped = true;
+					} else if (isOverlapped && _topLevels.Peek () == OverlappedTop) {
+						MoveCurrent (Top);
+						break;
 					}
-					Current = _topLevels.Peek ();
+					_topLevels.MoveNext ();
 				}
+				Current = _topLevels.Peek ();
 			}
 		}
+	}
 
-		/// <summary>
-		/// Move to the previous Overlapped child from the <see cref="OverlappedTop"/>.
-		/// </summary>
-		public static void OverlappedMovePrevious ()
-		{
-			if (OverlappedTop != null && !Current.Modal) {
-				lock (_topLevels) {
-					_topLevels.MovePrevious ();
-					var isOverlapped = false;
-					while (_topLevels.Peek () == OverlappedTop || !_topLevels.Peek ().Visible) {
-						if (!isOverlapped && _topLevels.Peek () == OverlappedTop) {
-							isOverlapped = true;
-						} else if (isOverlapped && _topLevels.Peek () == OverlappedTop) {
-							MoveCurrent (Top);
-							break;
-						}
-						_topLevels.MovePrevious ();
+	/// <summary>
+	/// Move to the previous Overlapped child from the <see cref="OverlappedTop"/>.
+	/// </summary>
+	public static void OverlappedMovePrevious ()
+	{
+		if (OverlappedTop != null && !Current.Modal) {
+			lock (_topLevels) {
+				_topLevels.MovePrevious ();
+				var isOverlapped = false;
+				while (_topLevels.Peek () == OverlappedTop || !_topLevels.Peek ().Visible) {
+					if (!isOverlapped && _topLevels.Peek () == OverlappedTop) {
+						isOverlapped = true;
+					} else if (isOverlapped && _topLevels.Peek () == OverlappedTop) {
+						MoveCurrent (Top);
+						break;
 					}
-					Current = _topLevels.Peek ();
+					_topLevels.MovePrevious ();
 				}
+				Current = _topLevels.Peek ();
 			}
 		}
+	}
 
-		/// <summary>
-		/// Move to the next Overlapped child from the <see cref="OverlappedTop"/> and set it as the <see cref="Top"/> if it is not already.
-		/// </summary>
-		/// <param name="top"></param>
-		/// <returns></returns>
-		public static bool MoveToOverlappedChild (Toplevel top)
-		{
-			if (top.Visible && OverlappedTop != null && Current?.Modal == false) {
-				lock (_topLevels) {
-					_topLevels.MoveTo (top, 0, new ToplevelEqualityComparer ());
-					Current = top;
-				}
-				return true;
-			}
-			return false;
+	/// <summary>
+	/// Move to the next Overlapped child from the <see cref="OverlappedTop"/> and set it as the
+	/// <see cref="Top"/> if it is not already.
+	/// </summary>
+	/// <param name="top"></param>
+	/// <returns></returns>
+	public static bool MoveToOverlappedChild (Toplevel top)
+	{
+		if (top.Visible && OverlappedTop != null && Current?.Modal == false) {
+			lock (_topLevels) {
+				_topLevels.MoveTo (top, 0, new ToplevelEqualityComparer ());
+				Current = top;
+			}
+			return true;
 		}
+		return false;
+	}
 
 
-		/// <summary>
-		/// Brings the superview of the most focused overlapped view is on front.
-		/// </summary>
-		public static void BringOverlappedTopToFront ()
-		{
-			if (OverlappedTop != null) {
-				return;
-			}
-			var top = FindTopFromView (Top?.MostFocused);
-			if (top != null && Top.Subviews.Count > 1 && Top.Subviews [Top.Subviews.Count - 1] != top) {
-				Top.BringSubviewToFront (top);
-			}
+	/// <summary>
+	/// Brings the superview of the most focused overlapped view is on front.
+	/// </summary>
+	public static void BringOverlappedTopToFront ()
+	{
+		if (OverlappedTop != null) {
+			return;
 		}
+		var top = FindTopFromView (Top?.MostFocused);
+		if (top != null && Top.Subviews.Count > 1 && Top.Subviews [Top.Subviews.Count - 1] != top) {
+			Top.BringSubviewToFront (top);
+		}
+	}
 
 
-		/// <summary>
-		/// Gets the current visible Toplevel overlapped child that matches the arguments pattern.
-		/// </summary>
-		/// <param name="type">The type.</param>
-		/// <param name="exclude">The strings to exclude.</param>
-		/// <returns>The matched view.</returns>
-		public static Toplevel GetTopOverlappedChild (Type type = null, string [] exclude = null)
-		{
-			if (Application.OverlappedTop == null) {
-				return null;
-			}
+	/// <summary>
+	/// Gets the current visible Toplevel overlapped child that matches the arguments pattern.
+	/// </summary>
+	/// <param name="type">The type.</param>
+	/// <param name="exclude">The strings to exclude.</param>
+	/// <returns>The matched view.</returns>
+	public static Toplevel GetTopOverlappedChild (Type type = null, string [] exclude = null)
+	{
+		if (OverlappedTop == null) {
+			return null;
+		}
 
-			foreach (var top in Application.OverlappedChildren) {
-				if (type != null && top.GetType () == type
-					&& exclude?.Contains (top.Data.ToString ()) == false) {
-					return top;
-				} else if ((type != null && top.GetType () != type)
-					|| (exclude?.Contains (top.Data.ToString ()) == true)) {
-					continue;
-				}
+		foreach (var top in OverlappedChildren) {
+			if (type != null && top.GetType () == type && exclude?.Contains (top.Data.ToString ()) == false) {
 				return top;
 			}
-			return null;
+			if (type != null && top.GetType () != type || exclude?.Contains (top.Data.ToString ()) == true) {
+				continue;
+			}
+			return top;
 		}
-
+		return null;
 	}
-}
+}

+ 156 - 156
UnitTests/Views/ToplevelTests.cs

@@ -5,9 +5,9 @@ using Xunit.Abstractions;
 namespace Terminal.Gui.ViewsTests;
 
 public class ToplevelTests {
-	readonly ITestOutputHelper output;
+	readonly ITestOutputHelper _output;
 
-	public ToplevelTests (ITestOutputHelper output) => this.output = output;
+	public ToplevelTests (ITestOutputHelper output) => _output = output;
 
 	[Fact]
 	[AutoInitShutdown]
@@ -16,8 +16,8 @@ public class ToplevelTests {
 		var top = new Toplevel ();
 
 		Assert.Equal (Colors.TopLevel, top.ColorScheme);
-		Assert.Equal ("Fill(0)", top.Width.ToString ());
-		Assert.Equal ("Fill(0)", top.Height.ToString ());
+		Assert.Equal ("Fill(0)",       top.Width.ToString ());
+		Assert.Equal ("Fill(0)",       top.Height.ToString ());
 		Assert.False (top.Running);
 		Assert.False (top.Modal);
 		Assert.Null (top.MenuBar);
@@ -157,7 +157,7 @@ public class ToplevelTests {
 	{
 		var top = new Toplevel ();
 
-		string eventInvoked = "";
+		var eventInvoked = "";
 
 		top.ChildUnloaded += (s, e) => eventInvoked = "ChildUnloaded";
 		top.OnChildUnloaded (top);
@@ -206,10 +206,10 @@ public class ToplevelTests {
 		Assert.Equal (top, Application.Top);
 
 		// Application.Top without menu and status bar.
-		var supView = top.GetLocationThatFits (top, 2, 2, out int nx, out int ny, out var mb, out var sb);
+		var supView = top.GetLocationThatFits (top, 2, 2, out var nx, out var ny, out var mb, out var sb);
 		Assert.Equal (Application.Top, supView);
-		Assert.Equal (0, nx);
-		Assert.Equal (0, ny);
+		Assert.Equal (0,               nx);
+		Assert.Equal (0,               ny);
 		Assert.Null (mb);
 		Assert.Null (sb);
 
@@ -251,7 +251,7 @@ public class ToplevelTests {
 		Assert.Null (top.StatusBar);
 		Assert.Null (top.MenuBar);
 
-		var win = new Window () { Width = Dim.Fill (), Height = Dim.Fill () };
+		var win = new Window { Width = Dim.Fill (), Height = Dim.Fill () };
 		top.Add (win);
 		top.LayoutSubviews ();
 
@@ -297,7 +297,7 @@ public class ToplevelTests {
 
 		top.Remove (win);
 
-		win = new Window () { Width = 60, Height = 15 };
+		win = new Window { Width = 60, Height = 15 };
 		top.Add (win);
 
 		// Application.Top without menu and status bar.
@@ -323,7 +323,7 @@ public class ToplevelTests {
 		// Application.Top with a menu and status bar.
 		top.GetLocationThatFits (win, 30, 20, out nx, out ny, out mb, out sb);
 		Assert.Equal (20, nx); // 20+60=80
-		Assert.Equal (9, ny); // 9+15+1(mb)=25
+		Assert.Equal (9,  ny); // 9+15+1(mb)=25
 		Assert.NotNull (mb);
 		Assert.NotNull (sb);
 
@@ -331,12 +331,12 @@ public class ToplevelTests {
 		Assert.Equal (new Rect (0, 1, 60, 15), win.Frame);
 
 		Assert.Null (Toplevel._dragPosition);
-		win.MouseEvent (new MouseEvent () { X = 6, Y = 0, Flags = MouseFlags.Button1Pressed });
+		win.MouseEvent (new MouseEvent { X = 6, Y = 0, Flags = MouseFlags.Button1Pressed });
 		Assert.Equal (new Point (6, 0), Toplevel._dragPosition);
-		win.MouseEvent (new MouseEvent () { X = 6, Y = 0, Flags = MouseFlags.Button1Released });
+		win.MouseEvent (new MouseEvent { X = 6, Y = 0, Flags = MouseFlags.Button1Released });
 		Assert.Null (Toplevel._dragPosition);
 		win.CanFocus = false;
-		win.MouseEvent (new MouseEvent () { X = 6, Y = 0, Flags = MouseFlags.Button1Pressed });
+		win.MouseEvent (new MouseEvent { X = 6, Y = 0, Flags = MouseFlags.Button1Pressed });
 		Assert.Null (Toplevel._dragPosition);
 	}
 
@@ -344,22 +344,22 @@ public class ToplevelTests {
 	[AutoInitShutdown]
 	public void KeyBindings_Command ()
 	{
-		bool isRunning = false;
+		var isRunning = false;
 
-		var win1 = new Window () { Id = "win1", Width = Dim.Percent (50f), Height = Dim.Fill () };
+		var win1 = new Window { Id = "win1", Width = Dim.Percent (50f), Height = Dim.Fill () };
 		var lblTf1W1 = new Label ("Enter text in TextField on Win1:") { Id = "lblTf1W1" };
 		var tf1W1 = new TextField ("Text1 on Win1") { Id = "tf1W1", X = Pos.Right (lblTf1W1) + 1, Width = Dim.Fill () };
 		var lblTvW1 = new Label ("Enter text in TextView on Win1:") { Id = "lblTvW1", Y = Pos.Bottom (lblTf1W1) + 1 };
-		var tvW1 = new TextView () { Id = "tvW1", X = Pos.Left (tf1W1), Width = Dim.Fill (), Height = 2, Text = "First line Win1\nSecond line Win1" };
+		var tvW1 = new TextView { Id = "tvW1", X = Pos.Left (tf1W1), Width = Dim.Fill (), Height = 2, Text = "First line Win1\nSecond line Win1" };
 		var lblTf2W1 = new Label ("Enter text in TextField on Win1:") { Id = "lblTf2W1", Y = Pos.Bottom (lblTvW1) + 1 };
 		var tf2W1 = new TextField ("Text2 on Win1") { Id = "tf2W1", X = Pos.Left (tf1W1), Width = Dim.Fill () };
 		win1.Add (lblTf1W1, tf1W1, lblTvW1, tvW1, lblTf2W1, tf2W1);
 
-		var win2 = new Window () { Id = "win2", X = Pos.Right (win1) + 1, Width = Dim.Percent (50f), Height = Dim.Fill () };
+		var win2 = new Window { Id = "win2", X = Pos.Right (win1) + 1, Width = Dim.Percent (50f), Height = Dim.Fill () };
 		var lblTf1W2 = new Label ("Enter text in TextField on Win2:") { Id = "lblTf1W2" };
 		var tf1W2 = new TextField ("Text1 on Win2") { Id = "tf1W2", X = Pos.Right (lblTf1W2) + 1, Width = Dim.Fill () };
 		var lblTvW2 = new Label ("Enter text in TextView on Win2:") { Id = "lblTvW2", Y = Pos.Bottom (lblTf1W2) + 1 };
-		var tvW2 = new TextView () { Id = "tvW2", X = Pos.Left (tf1W2), Width = Dim.Fill (), Height = 2, Text = "First line Win1\nSecond line Win2" };
+		var tvW2 = new TextView { Id = "tvW2", X = Pos.Left (tf1W2), Width = Dim.Fill (), Height = 2, Text = "First line Win1\nSecond line Win2" };
 		var lblTf2W2 = new Label ("Enter text in TextField on Win2:") { Id = "lblTf2W2", Y = Pos.Bottom (lblTvW2) + 1 };
 		var tf2W2 = new TextField ("Text2 on Win2") { Id = "tf2W2", X = Pos.Left (tf1W2), Width = Dim.Fill () };
 		win2.Add (lblTf1W2, tf1W2, lblTvW2, tvW2, lblTf2W2, tf2W2);
@@ -371,10 +371,10 @@ public class ToplevelTests {
 		Application.Begin (top);
 		top.Running = true;
 
-		Assert.Equal (new Rect (0, 0, 40, 25), win1.Frame);
+		Assert.Equal (new Rect (0,  0, 40, 25), win1.Frame);
 		Assert.Equal (new Rect (41, 0, 40, 25), win2.Frame);
-		Assert.Equal (win1, top.Focused);
-		Assert.Equal (tf1W1, top.MostFocused);
+		Assert.Equal (win1,                     top.Focused);
+		Assert.Equal (tf1W1,                    top.MostFocused);
 
 		Assert.True (isRunning);
 		Assert.True (Application.OnKeyDown (Application.QuitKey));
@@ -391,13 +391,13 @@ public class ToplevelTests {
 		Assert.True (Application.OnKeyDown (new Key (KeyCode.Tab | KeyCode.ShiftMask)));
 		Assert.Equal ($"First line Win1{Environment.NewLine}Second line Win1", tvW1.Text);
 		Assert.True (Application.OnKeyDown (new Key (KeyCode.Tab | KeyCode.CtrlMask)));
-		Assert.Equal (win1, top.Focused);
+		Assert.Equal (win1,  top.Focused);
 		Assert.Equal (tf2W1, top.MostFocused);
 		Assert.True (Application.OnKeyDown (new Key (KeyCode.Tab)));
-		Assert.Equal (win1, top.Focused);
+		Assert.Equal (win1,  top.Focused);
 		Assert.Equal (tf1W1, top.MostFocused);
 		Assert.True (Application.OnKeyDown (new Key (KeyCode.CursorRight)));
-		Assert.Equal (win1, top.Focused);
+		Assert.Equal (win1,  top.Focused);
 		Assert.Equal (tf1W1, top.MostFocused);
 		Assert.True (Application.OnKeyDown (new Key (KeyCode.CursorDown)));
 		Assert.Equal (win1, top.Focused);
@@ -411,22 +411,22 @@ public class ToplevelTests {
 		Assert.Equal (win1, top.Focused);
 		Assert.Equal (tvW1, top.MostFocused);
 		Assert.True (Application.OnKeyDown (new Key (KeyCode.CursorLeft)));
-		Assert.Equal (win1, top.Focused);
+		Assert.Equal (win1,  top.Focused);
 		Assert.Equal (tf1W1, top.MostFocused);
 		Assert.True (Application.OnKeyDown (new Key (KeyCode.CursorUp)));
-		Assert.Equal (win1, top.Focused);
+		Assert.Equal (win1,  top.Focused);
 		Assert.Equal (tf2W1, top.MostFocused);
 		Assert.True (Application.OnKeyDown (new Key (KeyCode.Tab | KeyCode.CtrlMask)));
-		Assert.Equal (win2, top.Focused);
+		Assert.Equal (win2,  top.Focused);
 		Assert.Equal (tf1W2, top.MostFocused);
 		Assert.True (Application.OnKeyDown (new Key (KeyCode.Tab | KeyCode.CtrlMask | KeyCode.ShiftMask)));
-		Assert.Equal (win1, top.Focused);
+		Assert.Equal (win1,  top.Focused);
 		Assert.Equal (tf2W1, top.MostFocused);
 		Assert.True (Application.OnKeyDown (Application.AlternateForwardKey));
-		Assert.Equal (win2, top.Focused);
+		Assert.Equal (win2,  top.Focused);
 		Assert.Equal (tf1W2, top.MostFocused);
 		Assert.True (Application.OnKeyDown (Application.AlternateBackwardKey));
-		Assert.Equal (win1, top.Focused);
+		Assert.Equal (win1,  top.Focused);
 		Assert.Equal (tf2W1, top.MostFocused);
 		Assert.True (Application.OnKeyDown (new Key (KeyCode.CursorUp)));
 		Assert.Equal (win1, top.Focused);
@@ -436,23 +436,23 @@ public class ToplevelTests {
 #else
 		Assert.True (Application.OnKeyDown (new Key (KeyCode.CursorLeft)));
 #endif
-		Assert.Equal (win1, top.Focused);
+		Assert.Equal (win1,  top.Focused);
 		Assert.Equal (tf1W1, top.MostFocused);
 
 		Assert.True (Application.OnKeyDown (new Key (KeyCode.CursorDown)));
-		Assert.Equal (win1, top.Focused);
-		Assert.Equal (tvW1, top.MostFocused);
+		Assert.Equal (win1,             top.Focused);
+		Assert.Equal (tvW1,             top.MostFocused);
 		Assert.Equal (new Point (0, 0), tvW1.CursorPosition);
 		Assert.True (Application.OnKeyDown (new Key (KeyCode.End | KeyCode.CtrlMask)));
-		Assert.Equal (win1, top.Focused);
-		Assert.Equal (tvW1, top.MostFocused);
+		Assert.Equal (win1,              top.Focused);
+		Assert.Equal (tvW1,              top.MostFocused);
 		Assert.Equal (new Point (16, 1), tvW1.CursorPosition);
 #if UNIX_KEY_BINDINGS
 			Assert.True (Application.OnKeyDown (new (Key.F | Key.CtrlMask)));
 #else
 		Assert.True (Application.OnKeyDown (new Key (KeyCode.CursorRight)));
 #endif
-		Assert.Equal (win1, top.Focused);
+		Assert.Equal (win1,  top.Focused);
 		Assert.Equal (tf2W1, top.MostFocused);
 
 #if UNIX_KEY_BINDINGS
@@ -472,22 +472,22 @@ public class ToplevelTests {
 		Application.Begin (top);
 		Assert.Equal (Application.Top, Application.OverlappedTop);
 
-		bool isRunning = true;
+		var isRunning = true;
 
-		var win1 = new Window () { Id = "win1", Width = Dim.Percent (50f), Height = Dim.Fill () };
+		var win1 = new Window { Id = "win1", Width = Dim.Percent (50f), Height = Dim.Fill () };
 		var lblTf1W1 = new Label ("Enter text in TextField on Win1:");
 		var tf1W1 = new TextField ("Text1 on Win1") { X = Pos.Right (lblTf1W1) + 1, Width = Dim.Fill () };
 		var lblTvW1 = new Label ("Enter text in TextView on Win1:") { Y = Pos.Bottom (lblTf1W1) + 1 };
-		var tvW1 = new TextView () { X = Pos.Left (tf1W1), Width = Dim.Fill (), Height = 2, Text = "First line Win1\nSecond line Win1" };
+		var tvW1 = new TextView { X = Pos.Left (tf1W1), Width = Dim.Fill (), Height = 2, Text = "First line Win1\nSecond line Win1" };
 		var lblTf2W1 = new Label ("Enter text in TextField on Win1:") { Y = Pos.Bottom (lblTvW1) + 1 };
 		var tf2W1 = new TextField ("Text2 on Win1") { X = Pos.Left (tf1W1), Width = Dim.Fill () };
 		win1.Add (lblTf1W1, tf1W1, lblTvW1, tvW1, lblTf2W1, tf2W1);
 
-		var win2 = new Window () { Id = "win2", Width = Dim.Percent (50f), Height = Dim.Fill () };
+		var win2 = new Window { Id = "win2", Width = Dim.Percent (50f), Height = Dim.Fill () };
 		var lblTf1W2 = new Label ("Enter text in TextField on Win2:");
 		var tf1W2 = new TextField ("Text1 on Win2") { X = Pos.Right (lblTf1W2) + 1, Width = Dim.Fill () };
 		var lblTvW2 = new Label ("Enter text in TextView on Win2:") { Y = Pos.Bottom (lblTf1W2) + 1 };
-		var tvW2 = new TextView () { X = Pos.Left (tf1W2), Width = Dim.Fill (), Height = 2, Text = "First line Win1\nSecond line Win2" };
+		var tvW2 = new TextView { X = Pos.Left (tf1W2), Width = Dim.Fill (), Height = 2, Text = "First line Win1\nSecond line Win2" };
 		var lblTf2W2 = new Label ("Enter text in TextField on Win2:") { Y = Pos.Bottom (lblTvW2) + 1 };
 		var tf2W2 = new TextField ("Text2 on Win2") { X = Pos.Left (tf1W2), Width = Dim.Fill () };
 		win2.Add (lblTf1W2, tf1W2, lblTvW2, tvW2, lblTf2W2, tf2W2);
@@ -519,7 +519,7 @@ public class ToplevelTests {
 		Assert.Null (top.Focused);
 		Assert.Null (top.MostFocused);
 		Assert.Equal (tf1W2, win2.MostFocused);
-		Assert.Equal (2, Application.OverlappedChildren.Count);
+		Assert.Equal (2,     Application.OverlappedChildren.Count);
 
 		Application.MoveToOverlappedChild (win1);
 		Assert.Equal (win1, Application.Current);
@@ -541,13 +541,13 @@ public class ToplevelTests {
 		Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.Tab | KeyCode.ShiftMask)));
 		Assert.Equal ($"First line Win1{Environment.NewLine}Second line Win1", tvW1.Text);
 		Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.Tab | KeyCode.CtrlMask)));
-		Assert.Equal (win1, Application.OverlappedChildren [0]);
+		Assert.Equal (win1,  Application.OverlappedChildren [0]);
 		Assert.Equal (tf2W1, win1.MostFocused);
 		Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.Tab)));
-		Assert.Equal (win1, Application.OverlappedChildren [0]);
+		Assert.Equal (win1,  Application.OverlappedChildren [0]);
 		Assert.Equal (tf1W1, win1.MostFocused);
 		Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.CursorRight)));
-		Assert.Equal (win1, Application.OverlappedChildren [0]);
+		Assert.Equal (win1,  Application.OverlappedChildren [0]);
 		Assert.Equal (tf1W1, win1.MostFocused);
 		Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.CursorDown)));
 		Assert.Equal (win1, Application.OverlappedChildren [0]);
@@ -561,27 +561,27 @@ public class ToplevelTests {
 		Assert.Equal (win1, Application.OverlappedChildren [0]);
 		Assert.Equal (tvW1, win1.MostFocused);
 		Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.CursorLeft)));
-		Assert.Equal (win1, Application.OverlappedChildren [0]);
+		Assert.Equal (win1,  Application.OverlappedChildren [0]);
 		Assert.Equal (tf1W1, win1.MostFocused);
 		Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.CursorUp)));
-		Assert.Equal (win1, Application.OverlappedChildren [0]);
+		Assert.Equal (win1,  Application.OverlappedChildren [0]);
 		Assert.Equal (tf2W1, win1.MostFocused);
 		Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.Tab)));
-		Assert.Equal (win1, Application.OverlappedChildren [0]);
+		Assert.Equal (win1,  Application.OverlappedChildren [0]);
 		Assert.Equal (tf1W1, win1.MostFocused);
 		Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.Tab | KeyCode.CtrlMask)));
-		Assert.Equal (win2, Application.OverlappedChildren [0]);
+		Assert.Equal (win2,  Application.OverlappedChildren [0]);
 		Assert.Equal (tf1W2, win2.MostFocused);
 		tf2W2.SetFocus ();
 		Assert.True (tf2W2.HasFocus);
 		Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.Tab | KeyCode.CtrlMask | KeyCode.ShiftMask)));
-		Assert.Equal (win1, Application.OverlappedChildren [0]);
+		Assert.Equal (win1,  Application.OverlappedChildren [0]);
 		Assert.Equal (tf1W1, win1.MostFocused);
 		Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (Application.AlternateForwardKey));
-		Assert.Equal (win2, Application.OverlappedChildren [0]);
+		Assert.Equal (win2,  Application.OverlappedChildren [0]);
 		Assert.Equal (tf2W2, win2.MostFocused);
 		Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (Application.AlternateBackwardKey));
-		Assert.Equal (win1, Application.OverlappedChildren [0]);
+		Assert.Equal (win1,  Application.OverlappedChildren [0]);
 		Assert.Equal (tf1W1, win1.MostFocused);
 		Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.CursorDown)));
 		Assert.Equal (win1, Application.OverlappedChildren [0]);
@@ -591,22 +591,22 @@ public class ToplevelTests {
 #else
 		Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.CursorLeft)));
 #endif
-		Assert.Equal (win1, Application.OverlappedChildren [0]);
+		Assert.Equal (win1,  Application.OverlappedChildren [0]);
 		Assert.Equal (tf1W1, win1.MostFocused);
 		Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.CursorDown)));
-		Assert.Equal (win1, Application.OverlappedChildren [0]);
-		Assert.Equal (tvW1, win1.MostFocused);
+		Assert.Equal (win1,             Application.OverlappedChildren [0]);
+		Assert.Equal (tvW1,             win1.MostFocused);
 		Assert.Equal (new Point (0, 0), tvW1.CursorPosition);
 		Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.End | KeyCode.CtrlMask)));
-		Assert.Equal (win1, Application.OverlappedChildren [0]);
-		Assert.Equal (tvW1, win1.MostFocused);
+		Assert.Equal (win1,              Application.OverlappedChildren [0]);
+		Assert.Equal (tvW1,              win1.MostFocused);
 		Assert.Equal (new Point (16, 1), tvW1.CursorPosition);
 #if UNIX_KEY_BINDINGS
 			Assert.True (Application.OverlappedChildren [0].ProcessKeyDown (new (Key.F | Key.CtrlMask)));
 #else
 		Assert.True (Application.OverlappedChildren [0].NewKeyDownEvent (new Key (KeyCode.CursorRight)));
 #endif
-		Assert.Equal (win1, Application.OverlappedChildren [0]);
+		Assert.Equal (win1,  Application.OverlappedChildren [0]);
 		Assert.Equal (tf2W1, win1.MostFocused);
 
 #if UNIX_KEY_BINDINGS
@@ -620,7 +620,7 @@ public class ToplevelTests {
 		Key alternateForwardKey = default;
 		Key alternateBackwardKey = default;
 		Key quitKey = default;
-		bool wasAdded = false;
+		var wasAdded = false;
 
 		var view = new View ();
 		view.Added += View_Added;
@@ -675,16 +675,16 @@ public class ToplevelTests {
 		Assert.Equal (KeyCode.Null, quitKey);
 
 		Assert.Equal (KeyCode.PageDown | KeyCode.CtrlMask, Application.AlternateForwardKey);
-		Assert.Equal (KeyCode.PageUp | KeyCode.CtrlMask, Application.AlternateBackwardKey);
-		Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, Application.QuitKey);
+		Assert.Equal (KeyCode.PageUp | KeyCode.CtrlMask,   Application.AlternateBackwardKey);
+		Assert.Equal (KeyCode.Q | KeyCode.CtrlMask,        Application.QuitKey);
 
 		Application.AlternateForwardKey = KeyCode.A;
 		Application.AlternateBackwardKey = KeyCode.B;
 		Application.QuitKey = KeyCode.C;
 
 		Assert.Equal (KeyCode.PageDown | KeyCode.CtrlMask, alternateForwardKey);
-		Assert.Equal (KeyCode.PageUp | KeyCode.CtrlMask, alternateBackwardKey);
-		Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, quitKey);
+		Assert.Equal (KeyCode.PageUp | KeyCode.CtrlMask,   alternateBackwardKey);
+		Assert.Equal (KeyCode.Q | KeyCode.CtrlMask,        quitKey);
 
 		Assert.Equal (KeyCode.A, Application.AlternateForwardKey);
 		Assert.Equal (KeyCode.B, Application.AlternateBackwardKey);
@@ -696,8 +696,8 @@ public class ToplevelTests {
 		Application.QuitKey = KeyCode.Q | KeyCode.CtrlMask;
 
 		Assert.Equal (KeyCode.PageDown | KeyCode.CtrlMask, Application.AlternateForwardKey);
-		Assert.Equal (KeyCode.PageUp | KeyCode.CtrlMask, Application.AlternateBackwardKey);
-		Assert.Equal (KeyCode.Q | KeyCode.CtrlMask, Application.QuitKey);
+		Assert.Equal (KeyCode.PageUp | KeyCode.CtrlMask,   Application.AlternateBackwardKey);
+		Assert.Equal (KeyCode.Q | KeyCode.CtrlMask,        Application.QuitKey);
 	}
 
 	[Fact]
@@ -707,7 +707,7 @@ public class ToplevelTests {
 		var win = new Window ();
 		var top = Application.Top;
 		top.Add (win);
-		int iterations = -1;
+		var iterations = -1;
 		Window testWindow;
 
 		Application.Iteration += (s, a) => {
@@ -715,7 +715,7 @@ public class ToplevelTests {
 			if (iterations == 0) {
 				((FakeDriver)Application.Driver).SetBufferSize (15, 7);
 				// Don't use MessageBox here; it's too complicated for this unit test; just use Window
-				testWindow = new Window () {
+				testWindow = new Window {
 					Text = "Hello",
 					X = 2,
 					Y = 2,
@@ -725,7 +725,7 @@ public class ToplevelTests {
 				Application.Run (testWindow);
 
 			} else if (iterations == 1) {
-				TestHelpers.AssertDriverContentsWithFrameAre (@$"
+				TestHelpers.AssertDriverContentsWithFrameAre (@"
 ┌─────────────┐
 │             │
 │ ┌────────┐  │
@@ -733,77 +733,77 @@ public class ToplevelTests {
 │ └────────┘  │
 │             │
 └─────────────┘
-", output);
+", _output);
 			} else if (iterations == 2) {
 				Assert.Null (Application.MouseGrabView);
 				// Grab the mouse
-				Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent () {
+				Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent {
 					X = 3,
 					Y = 2,
 					Flags = MouseFlags.Button1Pressed
 				}));
 
-				Assert.Equal (Application.Current, Application.MouseGrabView);
+				Assert.Equal (Application.Current,    Application.MouseGrabView);
 				Assert.Equal (new Rect (2, 2, 10, 3), Application.MouseGrabView.Frame);
 
 			} else if (iterations == 3) {
 				Assert.Equal (Application.Current, Application.MouseGrabView);
 				// Drag to left
-				Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent () {
+				Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent {
 					X = 2,
 					Y = 2,
 					Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition
 				}));
 				Application.Refresh ();
 
-				Assert.Equal (Application.Current, Application.MouseGrabView);
+				Assert.Equal (Application.Current,    Application.MouseGrabView);
 				Assert.Equal (new Rect (1, 2, 10, 3), Application.MouseGrabView.Frame);
 
 			} else if (iterations == 4) {
 				Assert.Equal (Application.Current, Application.MouseGrabView);
 
-				TestHelpers.AssertDriverContentsWithFrameAre (@$"
+				TestHelpers.AssertDriverContentsWithFrameAre (@"
 ┌─────────────┐
 │             │
 │┌────────┐   │
 ││Hello   │   │
 │└────────┘   │
 │             │
-└─────────────┘", output);
+└─────────────┘", _output);
 
 				Assert.Equal (Application.Current, Application.MouseGrabView);
 			} else if (iterations == 5) {
 				Assert.Equal (Application.Current, Application.MouseGrabView);
 				// Drag up
-				Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent () {
+				Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent {
 					X = 2,
 					Y = 1,
 					Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition
 				}));
 				Application.Refresh ();
 
-				Assert.Equal (Application.Current, Application.MouseGrabView);
+				Assert.Equal (Application.Current,    Application.MouseGrabView);
 				Assert.Equal (new Rect (1, 1, 10, 3), Application.MouseGrabView.Frame);
 
 			} else if (iterations == 6) {
 				Assert.Equal (Application.Current, Application.MouseGrabView);
 
-				TestHelpers.AssertDriverContentsWithFrameAre (@$"
+				TestHelpers.AssertDriverContentsWithFrameAre (@"
 ┌─────────────┐
 │┌────────┐   │
 ││Hello   │   │
 │└────────┘   │
 │             │
 │             │
-└─────────────┘", output);
+└─────────────┘", _output);
 
-				Assert.Equal (Application.Current, Application.MouseGrabView);
+				Assert.Equal (Application.Current,    Application.MouseGrabView);
 				Assert.Equal (new Rect (1, 1, 10, 3), Application.MouseGrabView.Frame);
 
 			} else if (iterations == 7) {
 				Assert.Equal (Application.Current, Application.MouseGrabView);
 				// Ungrab the mouse
-				Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent () {
+				Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent {
 					X = 2,
 					Y = 1,
 					Flags = MouseFlags.Button1Released
@@ -826,7 +826,7 @@ public class ToplevelTests {
 	[AutoInitShutdown]
 	public void Mouse_Drag_On_Top_With_Superview_Not_Null ()
 	{
-		var win = new Window () {
+		var win = new Window {
 			X = 3,
 			Y = 2,
 			Width = 10,
@@ -835,10 +835,10 @@ public class ToplevelTests {
 		var top = Application.Top;
 		top.Add (win);
 
-		int iterations = -1;
+		var iterations = -1;
 
-		int movex = 0;
-		int movey = 0;
+		var movex = 0;
+		var movey = 0;
 
 		var location = new Rect (win.Frame.X, win.Frame.Y, 7, 3);
 
@@ -851,20 +851,20 @@ public class ToplevelTests {
 
 				Assert.Null (Application.MouseGrabView);
 				// Grab the mouse
-				Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent () {
+				Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent {
 					X = win.Frame.X,
 					Y = win.Frame.Y,
 					Flags = MouseFlags.Button1Pressed
 				}));
 
-				Assert.Equal (win, Application.MouseGrabView);
+				Assert.Equal (win,      Application.MouseGrabView);
 				Assert.Equal (location, Application.MouseGrabView.Frame);
 			} else if (iterations == 2) {
 				Assert.Equal (win, Application.MouseGrabView);
 				// Drag to left
 				movex = 1;
 				movey = 0;
-				Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent () {
+				Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent {
 					X = win.Frame.X + movex,
 					Y = win.Frame.Y + movey,
 					Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition
@@ -884,7 +884,7 @@ public class ToplevelTests {
 				// Drag up
 				movex = 0;
 				movey = -1;
-				Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent () {
+				Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent {
 					X = win.Frame.X + movex,
 					Y = win.Frame.Y + movey,
 					Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition
@@ -903,7 +903,7 @@ public class ToplevelTests {
 				// Ungrab the mouse
 				movex = 0;
 				movey = 0;
-				Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent () {
+				Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent {
 					X = win.Frame.X + movex,
 					Y = win.Frame.Y + movey,
 					Flags = MouseFlags.Button1Released
@@ -936,8 +936,8 @@ public class ToplevelTests {
 	[AutoInitShutdown]
 	public void OnEnter_OnLeave_Triggered_On_Application_Begin_End ()
 	{
-		bool isEnter = false;
-		bool isLeave = false;
+		var isEnter = false;
+		var isLeave = false;
 		var v = new View ();
 		v.Enter += (s, _) => isEnter = true;
 		v.Leave += (s, _) => isLeave = true;
@@ -975,10 +975,10 @@ public class ToplevelTests {
 	[AutoInitShutdown]
 	public void OnEnter_OnLeave_Triggered_On_Application_Begin_End_With_More_Toplevels ()
 	{
-		int iterations = 0;
-		int [] steps = new int [5];
-		bool isEnterTop = false;
-		bool isLeaveTop = false;
+		var iterations = 0;
+		var steps = new int [5];
+		var isEnterTop = false;
+		var isLeaveTop = false;
 		var vt = new View ();
 		var top = Application.Top;
 		var diag = new Dialog ();
@@ -1015,8 +1015,8 @@ public class ToplevelTests {
 		Assert.False (isLeaveTop);
 
 		isEnterTop = false;
-		bool isEnterDiag = false;
-		bool isLeaveDiag = false;
+		var isEnterDiag = false;
+		var isLeaveDiag = false;
 		var vd = new View ();
 		vd.Enter += (s, e) => {
 			iterations++;
@@ -1067,7 +1067,7 @@ public class ToplevelTests {
 	public void PositionCursor_SetCursorVisibility_To_Invisible_If_Focused_Is_Null ()
 	{
 		var tf = new TextField ("test") { Width = 5 };
-		var view = new View () { Width = 10, Height = 10 };
+		var view = new View { Width = 10, Height = 10 };
 		view.Add (tf);
 		Application.Top.Add (view);
 		Application.Begin (Application.Top);
@@ -1137,23 +1137,23 @@ public class ToplevelTests {
 	[AutoInitShutdown]
 	public void Toplevel_Inside_ScrollView_MouseGrabView ()
 	{
-		var scrollView = new ScrollView () {
+		var scrollView = new ScrollView {
 			X = 3,
 			Y = 3,
 			Width = 40,
 			Height = 16,
 			ContentSize = new Size (200, 100)
 		};
-		var win = new Window () { X = 3, Y = 3, Width = Dim.Fill (3), Height = Dim.Fill (3) };
+		var win = new Window { X = 3, Y = 3, Width = Dim.Fill (3), Height = Dim.Fill (3) };
 		scrollView.Add (win);
 		var top = Application.Top;
 		top.Add (scrollView);
 		Application.Begin (top);
 
-		Assert.Equal (new Rect (0, 0, 80, 25), top.Frame);
-		Assert.Equal (new Rect (3, 3, 40, 16), scrollView.Frame);
+		Assert.Equal (new Rect (0, 0, 80,  25),  top.Frame);
+		Assert.Equal (new Rect (3, 3, 40,  16),  scrollView.Frame);
 		Assert.Equal (new Rect (0, 0, 200, 100), scrollView.Subviews [0].Frame);
-		Assert.Equal (new Rect (3, 3, 194, 94), win.Frame);
+		Assert.Equal (new Rect (3, 3, 194, 94),  win.Frame);
 		TestHelpers.AssertDriverContentsWithFrameAre (@"
@@ -1170,17 +1170,17 @@ public class ToplevelTests {
       │                                   ░
       │                                   ░
       │                                   ▼
-   ◄├──────┤░░░░░░░░░░░░░░░░░░░░░░░░░░░░░► ", output);
+   ◄├──────┤░░░░░░░░░░░░░░░░░░░░░░░░░░░░░► ", _output);
 
-		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent () {
+		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent {
 			X = 6,
 			Y = 6,
 			Flags = MouseFlags.Button1Pressed
 		}));
-		Assert.Equal (win, Application.MouseGrabView);
+		Assert.Equal (win,                      Application.MouseGrabView);
 		Assert.Equal (new Rect (3, 3, 194, 94), win.Frame);
 
-		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent () {
+		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent {
 			X = 9,
 			Y = 9,
 			Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition
@@ -1206,9 +1206,9 @@ public class ToplevelTests {
          │                                ░
          │                                ░
          │                                ▼
-   ◄├──────┤░░░░░░░░░░░░░░░░░░░░░░░░░░░░░► ", output);
+   ◄├──────┤░░░░░░░░░░░░░░░░░░░░░░░░░░░░░► ", _output);
 
-		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent () {
+		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent {
 			X = 5,
 			Y = 5,
 			Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition
@@ -1234,16 +1234,16 @@ public class ToplevelTests {
      │                                    ░
      │                                    ░
      │                                    ▼
-   ◄├──────┤░░░░░░░░░░░░░░░░░░░░░░░░░░░░░► ", output);
+   ◄├──────┤░░░░░░░░░░░░░░░░░░░░░░░░░░░░░► ", _output);
 
-		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent () {
+		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent {
 			X = 5,
 			Y = 5,
 			Flags = MouseFlags.Button1Released
 		}));
 		Assert.Null (Application.MouseGrabView);
 
-		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent () {
+		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent {
 			X = 4,
 			Y = 4,
 			Flags = MouseFlags.ReportMousePosition
@@ -1256,22 +1256,22 @@ public class ToplevelTests {
 	public void Window_Bounds_Bigger_Than_Driver_Cols_And_Rows_Allow_Drag_Beyond_Left_Right_And_Bottom ()
 	{
 		var top = Application.Top;
-		var window = new Window () { Width = 20, Height = 3 };
+		var window = new Window { Width = 20, Height = 3 };
 		Application.Begin (top);
 		((FakeDriver)Application.Driver).SetBufferSize (40, 10);
 		Application.Begin (window);
 		Application.Refresh ();
 		Assert.Equal (new Rect (0, 0, 40, 10), top.Frame);
-		Assert.Equal (new Rect (0, 0, 20, 3), window.Frame);
-		TestHelpers.AssertDriverContentsWithFrameAre (@$"
+		Assert.Equal (new Rect (0, 0, 20, 3),  window.Frame);
+		TestHelpers.AssertDriverContentsWithFrameAre (@"
 ┌──────────────────┐
 │                  │
 └──────────────────┘
-", output);
+", _output);
 
 		Assert.Null (Application.MouseGrabView);
 
-		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent () {
+		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent {
 			X = 0,
 			Y = 0,
 			Flags = MouseFlags.Button1Pressed
@@ -1279,7 +1279,7 @@ public class ToplevelTests {
 
 		Assert.Equal (window, Application.MouseGrabView);
 
-		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent () {
+		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent {
 			X = -11,
 			Y = -4,
 			Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition
@@ -1287,16 +1287,16 @@ public class ToplevelTests {
 
 		Application.Refresh ();
 		Assert.Equal (new Rect (0, 0, 40, 10), top.Frame);
-		Assert.Equal (new Rect (0, 0, 20, 3), window.Frame);
-		TestHelpers.AssertDriverContentsWithFrameAre (@$"
+		Assert.Equal (new Rect (0, 0, 20, 3),  window.Frame);
+		TestHelpers.AssertDriverContentsWithFrameAre (@"
 ┌──────────────────┐
 │                  │
 └──────────────────┘
-", output);
+", _output);
 
 		// Changes Top size to same size as Dialog more menu and scroll bar
 		((FakeDriver)Application.Driver).SetBufferSize (20, 3);
-		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent () {
+		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent {
 			X = -1,
 			Y = -1,
 			Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition
@@ -1305,51 +1305,51 @@ public class ToplevelTests {
 		Application.Refresh ();
 		Assert.Equal (new Rect (0, 0, 20, 3), top.Frame);
 		Assert.Equal (new Rect (0, 0, 20, 3), window.Frame);
-		TestHelpers.AssertDriverContentsWithFrameAre (@$"
+		TestHelpers.AssertDriverContentsWithFrameAre (@"
 ┌──────────────────┐
 │                  │
 └──────────────────┘
-", output);
+", _output);
 
 		// Changes Top size smaller than Dialog size
 		((FakeDriver)Application.Driver).SetBufferSize (19, 2);
-		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent () {
+		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent {
 			X = -1,
 			Y = -1,
 			Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition
 		}));
 
 		Application.Refresh ();
-		Assert.Equal (new Rect (0, 0, 19, 2), top.Frame);
+		Assert.Equal (new Rect (0,  0, 19, 2), top.Frame);
 		Assert.Equal (new Rect (-1, 0, 20, 3), window.Frame);
-		TestHelpers.AssertDriverContentsWithFrameAre (@$"
+		TestHelpers.AssertDriverContentsWithFrameAre (@"
 ──────────────────┐
-", output);
+", _output);
 
-		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent () {
+		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent {
 			X = 18,
 			Y = 1,
 			Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition
 		}));
 
 		Application.Refresh ();
-		Assert.Equal (new Rect (0, 0, 19, 2), top.Frame);
+		Assert.Equal (new Rect (0,  0, 19, 2), top.Frame);
 		Assert.Equal (new Rect (18, 1, 20, 3), window.Frame);
 		TestHelpers.AssertDriverContentsWithFrameAre (@"
-                  ┌", output);
+                  ┌", _output);
 
 		// On a real app we can't go beyond the SuperView bounds
-		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent () {
+		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent {
 			X = 19,
 			Y = 2,
 			Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition
 		}));
 
 		Application.Refresh ();
-		Assert.Equal (new Rect (0, 0, 19, 2), top.Frame);
+		Assert.Equal (new Rect (0,  0, 19, 2), top.Frame);
 		Assert.Equal (new Rect (19, 2, 20, 3), window.Frame);
-		TestHelpers.AssertDriverContentsWithFrameAre (@"", output);
+		TestHelpers.AssertDriverContentsWithFrameAre (@"", _output);
 	}
 
 	[Fact]
@@ -1357,7 +1357,7 @@ public class ToplevelTests {
 	public void Modal_As_Top_Will_Drag_Cleanly ()
 	{
 		// Don't use Dialog as a Top, use a Window instead - dialog has complex layout behavior that is not needed here.
-		var window = new Window () { Width = 10, Height = 3};
+		var window = new Window { Width = 10, Height = 3 };
 		window.Add (new Label (
 			"Test") {
 			X = Pos.Center (),
@@ -1376,15 +1376,15 @@ public class ToplevelTests {
 		TestHelpers.AssertDriverContentsWithFrameAre (@"
 ┌────────┐
 │  Test  │
-└────────┘", output);
+└────────┘", _output);
 
-		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent () {
+		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent {
 			X = 0,
 			Y = 0,
 			Flags = MouseFlags.Button1Pressed
 		}));
 
-		bool firstIteration = false;
+		var firstIteration = false;
 		Application.RunIteration (ref rs, ref firstIteration);
 		Assert.Equal (window, Application.MouseGrabView);
 
@@ -1392,9 +1392,9 @@ public class ToplevelTests {
 		TestHelpers.AssertDriverContentsWithFrameAre (@"
 ┌────────┐
 │  Test  │
-└────────┘", output);
+└────────┘", _output);
 
-		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent () {
+		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent {
 			X = 1,
 			Y = 1,
 			Flags = MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition
@@ -1402,12 +1402,12 @@ public class ToplevelTests {
 
 		firstIteration = false;
 		Application.RunIteration (ref rs, ref firstIteration);
-		Assert.Equal (window, Application.MouseGrabView);
-		Assert.Equal (new Rect (1, 1, 10,3), window.Frame);
+		Assert.Equal (window,                 Application.MouseGrabView);
+		Assert.Equal (new Rect (1, 1, 10, 3), window.Frame);
 		TestHelpers.AssertDriverContentsWithFrameAre (@"
  ┌────────┐
  │  Test  │
- └────────┘", output);
+ └────────┘", _output);
 
 		Application.End (rs);
 	}
@@ -1420,7 +1420,7 @@ public class ToplevelTests {
 		Application.Begin (top);
 		((FakeDriver)Application.Driver).SetBufferSize (20, 20);
 
-		var testWindow = new Window () { X = 2, Y = 1, Width = 15, Height = 10 };
+		var testWindow = new Window { X = 2, Y = 1, Width = 15, Height = 10 };
 		Assert.Equal (new Rect (2, 1, 15, 10), testWindow.Frame);
 
 		var rs = Application.Begin (testWindow);
@@ -1459,14 +1459,14 @@ public class ToplevelTests {
 │                  │
 │                  │
 │                  │
-└──────────────────┘", output);
+└──────────────────┘", _output);
 
 		var btnPopup = new Button ("Popup");
-		var testWindow = new Window () { X = 2, Y = 1, Width = 15, Height = 10 };
+		var testWindow = new Window { X = 2, Y = 1, Width = 15, Height = 10 };
 		testWindow.Add (btnPopup);
 		btnPopup.Clicked += (s, e) => {
 			var viewToScreen = btnPopup.BoundsToScreen (top.Frame);
-			var viewAddedToTop = new View () {
+			var viewAddedToTop = new View {
 				Text = "viewAddedToTop",
 				X = 1,
 				Y = viewToScreen.Y + 1,
@@ -1519,16 +1519,16 @@ public class ToplevelTests {
 │                  │
 │                  │
 │                  │
-└──────────────────┘", output);
+└──────────────────┘", _output);
 
-		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent () {
+		Application.OnMouseEvent (new MouseEventEventArgs (new MouseEvent {
 			X = 5,
 			Y = 2,
 			Flags = MouseFlags.Button1Clicked
 		}));
 		Application.Top.Draw ();
 
-		bool firstIteration = false;
+		var firstIteration = false;
 		Application.RunIteration (ref rs, ref firstIteration);
 		TestHelpers.AssertDriverContentsWithFrameAre (@$"
 ┌──────────────────┐
@@ -1550,7 +1550,7 @@ public class ToplevelTests {
 ││Two             ││
 ││Three           ││
 │└────────────────┘│
-└──────────────────┘", output);
+└──────────────────┘", _output);
 
 		Application.End (rs);
 	}
@@ -1586,9 +1586,9 @@ public class ToplevelTests {
 
 		int count = 0, count1 = 0, count2 = 0;
 		bool log = false, log1 = false, log2 = false;
-		bool fromTopStillKnowFirstIsRunning = false;
-		bool fromTopStillKnowSecondIsRunning = false;
-		bool fromFirstStillKnowSecondIsRunning = false;
+		var fromTopStillKnowFirstIsRunning = false;
+		var fromTopStillKnowSecondIsRunning = false;
+		var fromFirstStillKnowSecondIsRunning = false;
 
 		Application.AddTimeout (TimeSpan.FromMilliseconds (100), () => {
 			count++;