瀏覽代碼

Fixed SetupText issue

Tig 1 年之前
父節點
當前提交
695b8cf293

+ 0 - 22
Terminal.Gui/ConsoleDrivers/FakeDriver/FakeDriver.cs

@@ -40,28 +40,6 @@ public class FakeDriver : ConsoleDriver
     public static Behaviors FakeBehaviors = new ();
     public override bool SupportsTrueColor => false;
 
-    /// <inheritdoc />
-    public override int Cols
-    {
-        get => base.Cols;
-        internal set
-        {
-            base.Cols = value;
-            FakeConsole.SetBufferSize (Cols, Rows);
-        }
-    }
-
-    /// <inheritdoc />
-    public override int Rows
-    {
-        get => base.Rows;
-        internal set
-        {
-            base.Rows = value;
-            FakeConsole.SetBufferSize (Cols, Rows);
-        }
-    }
-
     public FakeDriver ()
     {
         Cols = FakeConsole.WindowWidth = FakeConsole.BufferWidth = FakeConsole.WIDTH;

+ 2 - 1
Terminal.Gui/View/ViewText.cs

@@ -9,10 +9,11 @@ public partial class View
     /// </summary>
     private void SetupText ()
     {
+        Text = string.Empty;
         TextDirection = TextDirection.LeftRight_TopBottom;
     }
 
-    private string _text = string.Empty;
+    private string _text;
 
     /// <summary>
     ///     Gets or sets whether trailing spaces at the end of word-wrapped lines are preserved

+ 7 - 9
UnitTests/Input/KeyBindingTests.cs

@@ -1,5 +1,4 @@
-using UICatalog.Scenarios;
-using Xunit.Abstractions;
+using Xunit.Abstractions;
 
 namespace Terminal.Gui.InputTests;
 
@@ -171,27 +170,26 @@ public class KeyBindingTests
         Command [] resultCommands = keyBindings.GetCommands (Key.A);
         Assert.DoesNotContain (Command.HotKey, resultCommands);
 
-        keyBindings = new KeyBindings ();
+        keyBindings = new ();
         keyBindings.Add (Key.A, KeyBindingScope.Focused, Command.HotKey);
         keyBindings.Add (Key.A, KeyBindingScope.Focused, Command.Accept);
 
         resultCommands = keyBindings.GetCommands (Key.A);
         Assert.DoesNotContain (Command.HotKey, resultCommands);
-        
-        keyBindings = new KeyBindings ();
+
+        keyBindings = new ();
         keyBindings.Add (Key.A, KeyBindingScope.HotKey, Command.HotKey);
         keyBindings.Add (Key.A, KeyBindingScope.Focused, Command.Accept);
 
         resultCommands = keyBindings.GetCommands (Key.A);
         Assert.DoesNotContain (Command.HotKey, resultCommands);
 
-        keyBindings = new KeyBindings ();
+        keyBindings = new ();
         keyBindings.Add (Key.A, new KeyBinding (new [] { Command.HotKey }, KeyBindingScope.HotKey));
         keyBindings.Add (Key.A, new KeyBinding (new [] { Command.Accept }, KeyBindingScope.HotKey));
 
         resultCommands = keyBindings.GetCommands (Key.A);
         Assert.DoesNotContain (Command.HotKey, resultCommands);
-
     }
 
     [Fact]
@@ -265,7 +263,7 @@ public class KeyBindingTests
         Assert.Contains (Command.Left, binding.Commands);
 
         // negative test
-        binding = keyBindings.Get (key, (KeyBindingScope)0);
+        binding = keyBindings.Get (key, 0);
         Assert.Null (binding);
 
         Command [] resultCommands = keyBindings.GetCommands (key);
@@ -293,7 +291,7 @@ public class KeyBindingTests
         Assert.Contains (Command.Left, binding.Commands);
 
         // negative test
-        success = keyBindings.TryGet (key, (KeyBindingScope)0, out binding);
+        success = keyBindings.TryGet (key, 0, out binding);
         Assert.False (success);
 
         Command [] resultCommands = keyBindings.GetCommands (key);

+ 1 - 3
UnitTests/TestHelpers.cs

@@ -77,7 +77,7 @@ public class AutoInitShutdownAttribute : BeforeAfterTestAttribute
         if (AutoInit)
         {
             // TODO: This Dispose call is here until all unit tests that don't correctly dispose Toplevel's they create are fixed.
-            //Application.Top?.Dispose ();
+            Application.Top?.Dispose ();
             Application.Shutdown ();
 #if DEBUG_IDISPOSABLE
             if (Responder.Instances.Count == 0)
@@ -171,8 +171,6 @@ public class SetupFakeDriverAttribute : BeforeAfterTestAttribute
         Debug.WriteLine ($"Before: {methodUnderTest.Name}");
         Assert.Null (Application.Driver);
         Application.Driver = new FakeDriver { Rows = 25, Cols = 25 };
-        Assert.Equal (FakeConsole.BufferWidth, Application.Driver.Cols);
-        Assert.Equal (FakeConsole.BufferHeight, Application.Driver.Rows);
         base.Before (methodUnderTest);
     }
 }

文件差異過大導致無法顯示
+ 238 - 137
UnitTests/Views/TextViewTests.cs


部分文件因文件數量過多而無法顯示