mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-01 16:59:35 +01:00
Merge branch 'v2_develop' into v2_3667_toplevel-menubar-statusbar-remove-fix
This commit is contained in:
@@ -4,33 +4,36 @@ using static Terminal.Gui.Dim;
|
||||
|
||||
namespace Terminal.Gui.LayoutTests;
|
||||
|
||||
[Trait("Category", "Layout")]
|
||||
public partial class DimAutoTests (ITestOutputHelper output)
|
||||
{
|
||||
private readonly ITestOutputHelper _output = output;
|
||||
|
||||
private class DimAutoTestView : View
|
||||
[SetupFakeDriver]
|
||||
[Fact]
|
||||
public void Change_To_Non_Auto_Resets_ContentSize ()
|
||||
{
|
||||
public DimAutoTestView ()
|
||||
View view = new ()
|
||||
{
|
||||
ValidatePosDim = true;
|
||||
Width = Auto ();
|
||||
Height = Auto ();
|
||||
}
|
||||
Width = Auto (),
|
||||
Height = Auto (),
|
||||
Text = "01234"
|
||||
};
|
||||
view.SetRelativeLayout (new (100, 100));
|
||||
Assert.Equal (new (0, 0, 5, 1), view.Frame);
|
||||
Assert.Equal (new (5, 1), view.GetContentSize ());
|
||||
|
||||
public DimAutoTestView (Dim width, Dim height)
|
||||
{
|
||||
ValidatePosDim = true;
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
// Change text to a longer string
|
||||
view.Text = "0123456789";
|
||||
|
||||
public DimAutoTestView (string text, Dim width, Dim height)
|
||||
{
|
||||
ValidatePosDim = true;
|
||||
Text = text;
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
Assert.Equal (new (0, 0, 10, 1), view.Frame);
|
||||
Assert.Equal (new (10, 1), view.GetContentSize ());
|
||||
|
||||
// If ContentSize was reset, these should cause it to update
|
||||
view.Width = 5;
|
||||
view.Height = 1;
|
||||
|
||||
Assert.Equal (new (5, 1), view.GetContentSize ());
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -74,6 +77,46 @@ public partial class DimAutoTests (ITestOutputHelper output)
|
||||
Assert.Equal (new (0, 0, 10, expectedHeight), superView.Frame);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[CombinatorialData]
|
||||
public void HotKey_TextFormatter_Height_Correct ([CombinatorialValues ("1234", "_1234", "1_234", "____")] string text)
|
||||
{
|
||||
View view = new ()
|
||||
{
|
||||
HotKeySpecifier = (Rune)'_',
|
||||
Text = text,
|
||||
Width = Auto (),
|
||||
Height = 1
|
||||
};
|
||||
Assert.Equal (4, view.TextFormatter.ConstrainToWidth);
|
||||
Assert.Equal (1, view.TextFormatter.ConstrainToHeight);
|
||||
|
||||
view = new ()
|
||||
{
|
||||
HotKeySpecifier = (Rune)'_',
|
||||
TextDirection = TextDirection.TopBottom_LeftRight,
|
||||
Text = text,
|
||||
Width = 1,
|
||||
Height = Auto ()
|
||||
};
|
||||
Assert.Equal (1, view.TextFormatter.ConstrainToWidth);
|
||||
Assert.Equal (4, view.TextFormatter.ConstrainToHeight);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[CombinatorialData]
|
||||
public void HotKey_TextFormatter_Width_Correct ([CombinatorialValues ("1234", "_1234", "1_234", "____")] string text)
|
||||
{
|
||||
View view = new ()
|
||||
{
|
||||
Text = text,
|
||||
Height = 1,
|
||||
Width = Auto ()
|
||||
};
|
||||
Assert.Equal (4, view.TextFormatter.ConstrainToWidth);
|
||||
Assert.Equal (1, view.TextFormatter.ConstrainToHeight);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NoSubViews_Does_Nothing ()
|
||||
{
|
||||
@@ -158,6 +201,122 @@ public partial class DimAutoTests (ITestOutputHelper output)
|
||||
Assert.Equal (new (0, 0, expectedWidth, expectedHeight), superView.Frame);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestEquality ()
|
||||
{
|
||||
var a = new DimAuto (
|
||||
MaximumContentDim: null,
|
||||
MinimumContentDim: 1,
|
||||
Style: DimAutoStyle.Auto
|
||||
);
|
||||
|
||||
var b = new DimAuto (
|
||||
MaximumContentDim: null,
|
||||
MinimumContentDim: 1,
|
||||
Style: DimAutoStyle.Auto
|
||||
);
|
||||
|
||||
var c = new DimAuto(
|
||||
MaximumContentDim: 2,
|
||||
MinimumContentDim: 1,
|
||||
Style: DimAutoStyle.Auto
|
||||
);
|
||||
|
||||
var d = new DimAuto (
|
||||
MaximumContentDim: null,
|
||||
MinimumContentDim: 1,
|
||||
Style: DimAutoStyle.Content
|
||||
);
|
||||
|
||||
var e = new DimAuto (
|
||||
MaximumContentDim: null,
|
||||
MinimumContentDim: 2,
|
||||
Style: DimAutoStyle.Auto
|
||||
);
|
||||
|
||||
// Test equality with same values
|
||||
Assert.True (a.Equals (b));
|
||||
Assert.True (a.GetHashCode () == b.GetHashCode ());
|
||||
|
||||
// Test inequality with different MaximumContentDim
|
||||
Assert.False (a.Equals (c));
|
||||
Assert.False (a.GetHashCode () == c.GetHashCode ());
|
||||
|
||||
// Test inequality with different Style
|
||||
Assert.False (a.Equals (d));
|
||||
Assert.False (a.GetHashCode () == d.GetHashCode ());
|
||||
|
||||
// Test inequality with different MinimumContentDim
|
||||
Assert.False (a.Equals (e));
|
||||
Assert.False (a.GetHashCode () == e.GetHashCode ());
|
||||
|
||||
// Test inequality with null
|
||||
Assert.False (a.Equals (null));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestEquality_Simple ()
|
||||
{
|
||||
Dim a = Auto ();
|
||||
Dim b = Auto ();
|
||||
Assert.True (a.Equals (b));
|
||||
Assert.True (a.GetHashCode () == b.GetHashCode ());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TextFormatter_Settings_Change_View_Size ()
|
||||
{
|
||||
View view = new ()
|
||||
{
|
||||
Text = "_1234",
|
||||
Width = Auto ()
|
||||
};
|
||||
Assert.Equal (new (4, 0), view.Frame.Size);
|
||||
|
||||
view.Height = 1;
|
||||
view.SetRelativeLayout (Application.Screen.Size);
|
||||
Assert.Equal (new (4, 1), view.Frame.Size);
|
||||
Size lastSize = view.Frame.Size;
|
||||
|
||||
view.TextAlignment = Alignment.Fill;
|
||||
Assert.Equal (lastSize, view.Frame.Size);
|
||||
|
||||
view = new ()
|
||||
{
|
||||
Text = "_1234",
|
||||
Width = Auto (),
|
||||
Height = 1
|
||||
};
|
||||
view.SetRelativeLayout (Application.Screen.Size);
|
||||
|
||||
lastSize = view.Frame.Size;
|
||||
view.VerticalTextAlignment = Alignment.Center;
|
||||
Assert.Equal (lastSize, view.Frame.Size);
|
||||
|
||||
view = new ()
|
||||
{
|
||||
Text = "_1234",
|
||||
Width = Auto (),
|
||||
Height = 1
|
||||
};
|
||||
view.SetRelativeLayout (Application.Screen.Size);
|
||||
lastSize = view.Frame.Size;
|
||||
view.HotKeySpecifier = (Rune)'*';
|
||||
view.SetRelativeLayout (Application.Screen.Size);
|
||||
Assert.NotEqual (lastSize, view.Frame.Size);
|
||||
|
||||
view = new ()
|
||||
{
|
||||
Text = "_1234",
|
||||
Width = Auto (),
|
||||
Height = 1
|
||||
};
|
||||
view.SetRelativeLayout (Application.Screen.Size);
|
||||
lastSize = view.Frame.Size;
|
||||
view.Text = "*ABCD";
|
||||
Assert.NotEqual (lastSize, view.Frame.Size);
|
||||
}
|
||||
|
||||
// Test validation
|
||||
[Fact]
|
||||
public void ValidatePosDim_True_Throws_When_SubView_Uses_SuperView_Dims ()
|
||||
@@ -410,46 +569,6 @@ public partial class DimAutoTests (ITestOutputHelper output)
|
||||
Assert.Equal (expectedWidth, superView.Frame.Width);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData (0, 1, 1)]
|
||||
[InlineData (1, 1, 1)]
|
||||
[InlineData (9, 1, 1)]
|
||||
[InlineData (10, 1, 1)]
|
||||
[InlineData (0, 10, 10)]
|
||||
[InlineData (1, 10, 10)]
|
||||
[InlineData (9, 10, 10)]
|
||||
[InlineData (10, 10, 10)]
|
||||
public void Width_Auto_Text_Does_Not_Constrain_To_SuperView (int subX, int textLen, int expectedSubWidth)
|
||||
{
|
||||
var superView = new View
|
||||
{
|
||||
X = 0,
|
||||
Y = 0,
|
||||
Width = 10,
|
||||
Height = 1,
|
||||
ValidatePosDim = true
|
||||
};
|
||||
|
||||
var subView = new View
|
||||
{
|
||||
Text = new ('*', textLen),
|
||||
X = subX,
|
||||
Y = 0,
|
||||
Width = Auto (DimAutoStyle.Text),
|
||||
Height = 1,
|
||||
ValidatePosDim = true
|
||||
};
|
||||
|
||||
superView.Add (subView);
|
||||
|
||||
superView.BeginInit ();
|
||||
superView.EndInit ();
|
||||
superView.SetRelativeLayout (superView.GetContentSize ());
|
||||
|
||||
superView.LayoutSubviews ();
|
||||
Assert.Equal (expectedSubWidth, subView.Frame.Width);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData (0, 1, 1)]
|
||||
[InlineData (1, 1, 1)]
|
||||
@@ -499,31 +618,69 @@ public partial class DimAutoTests (ITestOutputHelper output)
|
||||
Assert.Equal (expectedSubWidth, subView.Frame.Width);
|
||||
}
|
||||
|
||||
[SetupFakeDriver]
|
||||
[Fact]
|
||||
public void Change_To_Non_Auto_Resets_ContentSize ()
|
||||
[Theory]
|
||||
[InlineData (0, 1, 1)]
|
||||
[InlineData (1, 1, 1)]
|
||||
[InlineData (9, 1, 1)]
|
||||
[InlineData (10, 1, 1)]
|
||||
[InlineData (0, 10, 10)]
|
||||
[InlineData (1, 10, 10)]
|
||||
[InlineData (9, 10, 10)]
|
||||
[InlineData (10, 10, 10)]
|
||||
public void Width_Auto_Text_Does_Not_Constrain_To_SuperView (int subX, int textLen, int expectedSubWidth)
|
||||
{
|
||||
View view = new ()
|
||||
var superView = new View
|
||||
{
|
||||
Width = Auto (),
|
||||
Height = Auto (),
|
||||
Text = "01234"
|
||||
X = 0,
|
||||
Y = 0,
|
||||
Width = 10,
|
||||
Height = 1,
|
||||
ValidatePosDim = true
|
||||
};
|
||||
view.SetRelativeLayout (new (100, 100));
|
||||
Assert.Equal (new (0, 0, 5, 1), view.Frame);
|
||||
Assert.Equal (new (5, 1), view.GetContentSize ());
|
||||
|
||||
// Change text to a longer string
|
||||
view.Text = "0123456789";
|
||||
var subView = new View
|
||||
{
|
||||
Text = new ('*', textLen),
|
||||
X = subX,
|
||||
Y = 0,
|
||||
Width = Auto (DimAutoStyle.Text),
|
||||
Height = 1,
|
||||
ValidatePosDim = true
|
||||
};
|
||||
|
||||
Assert.Equal (new (0, 0, 10, 1), view.Frame);
|
||||
Assert.Equal (new (10, 1), view.GetContentSize ());
|
||||
superView.Add (subView);
|
||||
|
||||
// If ContentSize was reset, these should cause it to update
|
||||
view.Width = 5;
|
||||
view.Height = 1;
|
||||
superView.BeginInit ();
|
||||
superView.EndInit ();
|
||||
superView.SetRelativeLayout (superView.GetContentSize ());
|
||||
|
||||
Assert.Equal (new (5, 1), view.GetContentSize ());
|
||||
superView.LayoutSubviews ();
|
||||
Assert.Equal (expectedSubWidth, subView.Frame.Width);
|
||||
}
|
||||
|
||||
private class DimAutoTestView : View
|
||||
{
|
||||
public DimAutoTestView ()
|
||||
{
|
||||
ValidatePosDim = true;
|
||||
Width = Auto ();
|
||||
Height = Auto ();
|
||||
}
|
||||
|
||||
public DimAutoTestView (Dim width, Dim height)
|
||||
{
|
||||
ValidatePosDim = true;
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
|
||||
public DimAutoTestView (string text, Dim width, Dim height)
|
||||
{
|
||||
ValidatePosDim = true;
|
||||
Text = text;
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
}
|
||||
|
||||
#region DimAutoStyle.Auto tests
|
||||
@@ -544,7 +701,6 @@ public partial class DimAutoTests (ITestOutputHelper output)
|
||||
view.SetRelativeLayout (Application.Screen.Size);
|
||||
|
||||
Assert.Equal (new (expectedW, expectedH), view.Frame.Size);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -653,7 +809,6 @@ public partial class DimAutoTests (ITestOutputHelper output)
|
||||
view.SetRelativeLayout (Application.Screen.Size);
|
||||
|
||||
Assert.Equal (new (expectedW, expectedH), view.Frame.Size);
|
||||
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -665,15 +820,14 @@ public partial class DimAutoTests (ITestOutputHelper output)
|
||||
public void DimAutoStyle_Text_Sizes_Correctly_With_Min (string text, int minWidth, int minHeight, int expectedW, int expectedH)
|
||||
{
|
||||
var view = new View ();
|
||||
view.Width = Auto (DimAutoStyle.Text, minimumContentDim: minWidth);
|
||||
view.Height = Auto (DimAutoStyle.Text, minimumContentDim: minHeight);
|
||||
view.Width = Auto (DimAutoStyle.Text, minWidth);
|
||||
view.Height = Auto (DimAutoStyle.Text, minHeight);
|
||||
|
||||
view.Text = text;
|
||||
|
||||
view.SetRelativeLayout (Application.Screen.Size);
|
||||
|
||||
Assert.Equal (new (expectedW, expectedH), view.Frame.Size);
|
||||
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -699,7 +853,6 @@ public partial class DimAutoTests (ITestOutputHelper output)
|
||||
[InlineData ("01234", 5, 1)]
|
||||
[InlineData ("01234ABCDE", 10, 1)]
|
||||
[InlineData ("01234\nABCDE", 5, 2)]
|
||||
|
||||
public void DimAutoStyle_Text_NoMin_Not_Constrained_By_ContentSize (string text, int expectedW, int expectedH)
|
||||
{
|
||||
var view = new View ();
|
||||
@@ -711,7 +864,6 @@ public partial class DimAutoTests (ITestOutputHelper output)
|
||||
Assert.Equal (new (expectedW, expectedH), view.Frame.Size);
|
||||
}
|
||||
|
||||
|
||||
[Theory]
|
||||
[InlineData ("", 0, 0)]
|
||||
[InlineData (" ", 1, 1)]
|
||||
@@ -720,7 +872,7 @@ public partial class DimAutoTests (ITestOutputHelper output)
|
||||
[InlineData ("01234\nABCDE", 5, 2)]
|
||||
public void DimAutoStyle_Text_NoMin_Not_Constrained_By_SuperView (string text, int expectedW, int expectedH)
|
||||
{
|
||||
var superView = new View ()
|
||||
var superView = new View
|
||||
{
|
||||
Width = 1, Height = 1
|
||||
};
|
||||
@@ -870,100 +1022,5 @@ public partial class DimAutoTests (ITestOutputHelper output)
|
||||
|
||||
#endregion DimAutoStyle.Content tests
|
||||
|
||||
[Fact]
|
||||
public void TextFormatter_Settings_Change_View_Size ()
|
||||
{
|
||||
View view = new ()
|
||||
{
|
||||
Text = "_1234",
|
||||
Width = Auto ()
|
||||
};
|
||||
Assert.Equal (new (4, 0), view.Frame.Size);
|
||||
|
||||
view.Height = 1;
|
||||
view.SetRelativeLayout (Application.Screen.Size);
|
||||
Assert.Equal (new (4, 1), view.Frame.Size);
|
||||
Size lastSize = view.Frame.Size;
|
||||
|
||||
view.TextAlignment = Alignment.Fill;
|
||||
Assert.Equal (lastSize, view.Frame.Size);
|
||||
|
||||
view = new ()
|
||||
{
|
||||
Text = "_1234",
|
||||
Width = Auto (),
|
||||
Height = 1
|
||||
};
|
||||
view.SetRelativeLayout (Application.Screen.Size);
|
||||
|
||||
lastSize = view.Frame.Size;
|
||||
view.VerticalTextAlignment = Alignment.Center;
|
||||
Assert.Equal (lastSize, view.Frame.Size);
|
||||
|
||||
view = new ()
|
||||
{
|
||||
Text = "_1234",
|
||||
Width = Auto (),
|
||||
Height = 1
|
||||
};
|
||||
view.SetRelativeLayout (Application.Screen.Size);
|
||||
lastSize = view.Frame.Size;
|
||||
view.HotKeySpecifier = (Rune)'*';
|
||||
view.SetRelativeLayout (Application.Screen.Size);
|
||||
Assert.NotEqual (lastSize, view.Frame.Size);
|
||||
|
||||
view = new ()
|
||||
{
|
||||
Text = "_1234",
|
||||
Width = Auto (),
|
||||
Height = 1
|
||||
};
|
||||
view.SetRelativeLayout (Application.Screen.Size);
|
||||
lastSize = view.Frame.Size;
|
||||
view.Text = "*ABCD";
|
||||
Assert.NotEqual (lastSize, view.Frame.Size);
|
||||
}
|
||||
|
||||
|
||||
[Theory]
|
||||
[CombinatorialData]
|
||||
public void HotKey_TextFormatter_Width_Correct ([CombinatorialValues ("1234", "_1234", "1_234", "____")] string text)
|
||||
{
|
||||
View view = new ()
|
||||
{
|
||||
Text = text,
|
||||
Height = 1,
|
||||
Width = Auto ()
|
||||
};
|
||||
Assert.Equal (4, view.TextFormatter.ConstrainToWidth);
|
||||
Assert.Equal (1, view.TextFormatter.ConstrainToHeight);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[CombinatorialData]
|
||||
public void HotKey_TextFormatter_Height_Correct ([CombinatorialValues ("1234", "_1234", "1_234", "____")] string text)
|
||||
{
|
||||
View view = new ()
|
||||
{
|
||||
HotKeySpecifier = (Rune)'_',
|
||||
Text = text,
|
||||
Width = Auto (),
|
||||
Height = 1
|
||||
};
|
||||
Assert.Equal (4, view.TextFormatter.ConstrainToWidth);
|
||||
Assert.Equal (1, view.TextFormatter.ConstrainToHeight);
|
||||
|
||||
view = new ()
|
||||
{
|
||||
HotKeySpecifier = (Rune)'_',
|
||||
TextDirection = TextDirection.TopBottom_LeftRight,
|
||||
Text = text,
|
||||
Width = 1,
|
||||
Height = Auto ()
|
||||
};
|
||||
Assert.Equal (1, view.TextFormatter.ConstrainToWidth);
|
||||
Assert.Equal (4, view.TextFormatter.ConstrainToHeight);
|
||||
}
|
||||
|
||||
// Test variations of Frame
|
||||
}
|
||||
|
||||
@@ -14,9 +14,12 @@ public class DimFuncTests (ITestOutputHelper output)
|
||||
Func<int> f2 = () => 0;
|
||||
|
||||
Dim dim1 = Func (f1);
|
||||
Dim dim2 = Func (f2);
|
||||
Dim dim2 = Func (f1);
|
||||
Assert.Equal (dim1, dim2);
|
||||
|
||||
dim2 = Func (f2);
|
||||
Assert.NotEqual (dim1, dim2);
|
||||
|
||||
f2 = () => 1;
|
||||
dim2 = Func (f2);
|
||||
Assert.NotEqual (dim1, dim2);
|
||||
|
||||
@@ -15,7 +15,6 @@ public class DimPercentTests
|
||||
Assert.Equal (50, result);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void DimPercent_Equals ()
|
||||
{
|
||||
@@ -63,6 +62,15 @@ public class DimPercentTests
|
||||
Assert.NotEqual (dim1, dim2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestEquality ()
|
||||
{
|
||||
var a = Dim.Percent (32);
|
||||
var b = Dim.Percent (32);
|
||||
Assert.True (a.Equals (b));
|
||||
Assert.True (a.GetHashCode () == b.GetHashCode ());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DimPercent_Invalid_Throws ()
|
||||
{
|
||||
@@ -157,7 +165,7 @@ public class DimPercentTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(0)]
|
||||
[InlineData (0)]
|
||||
[InlineData (1)]
|
||||
[InlineData (50)]
|
||||
[InlineData (100)]
|
||||
|
||||
@@ -27,58 +27,58 @@ public class PosAlignTests
|
||||
Assert.Equal (0, posAlign.Aligner.ContainerSize);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData (Alignment.Start, Alignment.Start, AlignmentModes.AddSpaceBetweenItems, AlignmentModes.AddSpaceBetweenItems, true)]
|
||||
[InlineData (Alignment.Center, Alignment.Center, AlignmentModes.AddSpaceBetweenItems, AlignmentModes.AddSpaceBetweenItems, true)]
|
||||
[InlineData (Alignment.Start, Alignment.Center, AlignmentModes.AddSpaceBetweenItems, AlignmentModes.AddSpaceBetweenItems, false)]
|
||||
[InlineData (Alignment.Center, Alignment.Start, AlignmentModes.AddSpaceBetweenItems, AlignmentModes.AddSpaceBetweenItems, false)]
|
||||
[InlineData (Alignment.Start, Alignment.Start, AlignmentModes.StartToEnd, AlignmentModes.AddSpaceBetweenItems, false)]
|
||||
public void PosAlign_Equals (Alignment align1, Alignment align2, AlignmentModes mode1, AlignmentModes mode2, bool expectedEquals)
|
||||
{
|
||||
var posAlign1 = new PosAlign
|
||||
{
|
||||
Aligner = new()
|
||||
{
|
||||
Alignment = align1,
|
||||
AlignmentModes = mode1
|
||||
}
|
||||
};
|
||||
//[Theory]
|
||||
//[InlineData (Alignment.Start, Alignment.Start, AlignmentModes.AddSpaceBetweenItems, AlignmentModes.AddSpaceBetweenItems, true)]
|
||||
//[InlineData (Alignment.Center, Alignment.Center, AlignmentModes.AddSpaceBetweenItems, AlignmentModes.AddSpaceBetweenItems, true)]
|
||||
//[InlineData (Alignment.Start, Alignment.Center, AlignmentModes.AddSpaceBetweenItems, AlignmentModes.AddSpaceBetweenItems, false)]
|
||||
//[InlineData (Alignment.Center, Alignment.Start, AlignmentModes.AddSpaceBetweenItems, AlignmentModes.AddSpaceBetweenItems, false)]
|
||||
//[InlineData (Alignment.Start, Alignment.Start, AlignmentModes.StartToEnd, AlignmentModes.AddSpaceBetweenItems, false)]
|
||||
//public void PosAlign_Equals (Alignment align1, Alignment align2, AlignmentModes mode1, AlignmentModes mode2, bool expectedEquals)
|
||||
//{
|
||||
// var posAlign1 = new PosAlign
|
||||
// {
|
||||
// Aligner = new ()
|
||||
// {
|
||||
// Alignment = align1,
|
||||
// AlignmentModes = mode1
|
||||
// }
|
||||
// };
|
||||
|
||||
var posAlign2 = new PosAlign
|
||||
{
|
||||
Aligner = new()
|
||||
{
|
||||
Alignment = align2,
|
||||
AlignmentModes = mode2
|
||||
}
|
||||
};
|
||||
// var posAlign2 = new PosAlign
|
||||
// {
|
||||
// Aligner = new ()
|
||||
// {
|
||||
// Alignment = align2,
|
||||
// AlignmentModes = mode2
|
||||
// }
|
||||
// };
|
||||
|
||||
Assert.Equal (expectedEquals, posAlign1.Equals (posAlign2));
|
||||
Assert.Equal (expectedEquals, posAlign2.Equals (posAlign1));
|
||||
}
|
||||
// Assert.Equal (expectedEquals, posAlign1.Equals (posAlign2));
|
||||
// Assert.Equal (expectedEquals, posAlign2.Equals (posAlign1));
|
||||
//}
|
||||
|
||||
[Fact]
|
||||
public void PosAlign_Equals_CachedLocation_Not_Used ()
|
||||
{
|
||||
View superView = new ()
|
||||
{
|
||||
Width = 10,
|
||||
Height = 25
|
||||
};
|
||||
View view = new ();
|
||||
superView.Add (view);
|
||||
//[Fact]
|
||||
//public void PosAlign_Equals_CachedLocation_Not_Used ()
|
||||
//{
|
||||
// View superView = new ()
|
||||
// {
|
||||
// Width = 10,
|
||||
// Height = 25
|
||||
// };
|
||||
// View view = new ();
|
||||
// superView.Add (view);
|
||||
|
||||
Pos posAlign1 = Pos.Align (Alignment.Center);
|
||||
view.X = posAlign1;
|
||||
int pos1 = posAlign1.Calculate (10, Dim.Absolute (0)!, view, Dimension.Width);
|
||||
// Pos posAlign1 = Pos.Align (Alignment.Center);
|
||||
// view.X = posAlign1;
|
||||
// int pos1 = posAlign1.Calculate (10, Dim.Absolute (0)!, view, Dimension.Width);
|
||||
|
||||
Pos posAlign2 = Pos.Align (Alignment.Center);
|
||||
view.Y = posAlign2;
|
||||
int pos2 = posAlign2.Calculate (25, Dim.Absolute (0)!, view, Dimension.Height);
|
||||
// Pos posAlign2 = Pos.Align (Alignment.Center);
|
||||
// view.Y = posAlign2;
|
||||
// int pos2 = posAlign2.Calculate (25, Dim.Absolute (0)!, view, Dimension.Height);
|
||||
|
||||
Assert.NotEqual (pos1, pos2);
|
||||
Assert.Equal (posAlign1, posAlign2);
|
||||
}
|
||||
// Assert.NotEqual (pos1, pos2);
|
||||
// Assert.Equal (posAlign1, posAlign2);
|
||||
//}
|
||||
|
||||
[Fact]
|
||||
public void PosAlign_ToString ()
|
||||
|
||||
@@ -27,15 +27,6 @@ public class PosAnchorEndTests (ITestOutputHelper output)
|
||||
Assert.Equal (expectedEquals, posAnchorEnd2.Equals (posAnchorEnd1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PosAnchorEnd_GetHashCode ()
|
||||
{
|
||||
var posAnchorEnd = new PosAnchorEnd (10);
|
||||
var expectedHashCode = 10.GetHashCode ();
|
||||
|
||||
Assert.Equal (expectedHashCode, posAnchorEnd.GetHashCode ());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PosAnchorEnd_ToString ()
|
||||
{
|
||||
|
||||
@@ -15,16 +15,6 @@ public class PosCenterTests (ITestOutputHelper output)
|
||||
Assert.NotNull (posCenter);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PosCenter_Equals ()
|
||||
{
|
||||
var posCenter1 = new PosCenter ();
|
||||
var posCenter2 = new PosCenter ();
|
||||
|
||||
Assert.False (posCenter1.Equals (posCenter2));
|
||||
Assert.False (posCenter2.Equals (posCenter1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PosCenter_ToString ()
|
||||
{
|
||||
|
||||
@@ -13,7 +13,7 @@ public class PosFuncTests (ITestOutputHelper output)
|
||||
Func<int> f2 = () => 0;
|
||||
|
||||
Pos pos1 = Pos.Func (f1);
|
||||
Pos pos2 = Pos.Func (f2);
|
||||
Pos pos2 = Pos.Func (f1);
|
||||
Assert.Equal (pos1, pos2);
|
||||
|
||||
f2 = () => 1;
|
||||
|
||||
@@ -145,21 +145,6 @@ public class PosTests ()
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PosFunction_Equal ()
|
||||
{
|
||||
Func<int> f1 = () => 0;
|
||||
Func<int> f2 = () => 0;
|
||||
|
||||
Pos pos1 = Pos.Func (f1);
|
||||
Pos pos2 = Pos.Func (f2);
|
||||
Assert.Equal (pos1, pos2);
|
||||
|
||||
f2 = () => 1;
|
||||
pos2 = Pos.Func (f2);
|
||||
Assert.NotEqual (pos1, pos2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PosFunction_SetsValue ()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user