Fixing tests...

This commit is contained in:
Tig
2024-04-18 13:14:22 -06:00
parent a48146af82
commit f3b5ed7afc
7 changed files with 454 additions and 417 deletions

View File

@@ -1,6 +1,8 @@
using System.Globalization;
using System.Text;
using Xunit.Abstractions;
using static Terminal.Gui.Dim;
// Alias Console to MockConsole so we don't accidentally use Console
using Console = Terminal.Gui.FakeConsole;
@@ -587,7 +589,7 @@ public class DimAutoTests
[InlineData (1, 10, 10)]
[InlineData (9, 10, 10)]
[InlineData (10, 10, 10)]
public void Width_Auto_Subviews_Does_Not_Constrain_To_SuperView (int subX, int textLen, int expectedSubWidth)
public void Width_Auto_Subviews_Does_Not_Constrain_To_SuperView (int subX, int subSubViewWidth, int expectedSubWidth)
{
var superView = new View
{
@@ -600,7 +602,6 @@ public class DimAutoTests
var subView = new View
{
Text = new string ('*', textLen),
X = subX,
Y = 0,
Width = Dim.Auto (Dim.DimAutoStyle.Subviews),
@@ -608,6 +609,16 @@ public class DimAutoTests
ValidatePosDim = true
};
var subSubView = new View
{
X = 0,
Y = 0,
Width = subSubViewWidth,
Height = 1,
ValidatePosDim = true
};
subView.Add (subSubView);
superView.Add (subView);
superView.BeginInit ();
@@ -618,5 +629,32 @@ public class DimAutoTests
Assert.Equal (expectedSubWidth, subView.Frame.Width);
}
[Fact]
public void DimAuto_Text_Viewport_Stays_Set ()
{
var super = new View ()
{
Width = Dim.Fill (),
Height = Dim.Fill ()
};
var view = new View ()
{
Width = Auto (DimAutoStyle.Text),
Height = Auto (DimAutoStyle.Text),
Text = "New text"
};
Rectangle expectedViewport = new (0, 0, 8, 1);
Assert.Equal (expectedViewport, view.Viewport);
super.Add (view);
Assert.Equal (expectedViewport, view.Viewport);
super.LayoutSubviews ();
Assert.Equal (expectedViewport, view.Viewport);
super.Dispose ();
}
// Test variations of Frame
}