Files
Terminal.Gui/Tests/UnitTestsParallelizable/View/Layout/Dim.ViewTests.cs
Tig acb5979e6c Cleans up/Refactors View.Subviews (#3962)
* Subview clean up

* New Add/Remove event pattern

* Using Logging

* cleanup

* Subview -> SubView

* Test code cleanup. Killed many warnings.

* Fix tznind feedback

* Refactored AllViewTest helpers

* Moved keyboard tests to parallel

* Moved mouse tests to parallel

* Moved view tests to parallel

* Test code cleanup. Killed many warnings.

* dupe test

* Some mouse tests can't run in parallel because MouseGrabView

* Made SpinnerView more testable

* Moved more tests

* SubViews to IReadOnlyCollection<View>

* SubViews to IReadOnlyCollection<View> 2

* scrollbar tests

* shortcut tests

* Use InternalSubViews vs. _subviews

* Nuked View.IsAdded.
Added View.SuperViewChanged.

* API doc updats

* Unit Test tweak

* Unit Test tweak
2025-03-08 15:42:17 -07:00

57 lines
1.5 KiB
C#

using static Terminal.Gui.Dim;
namespace Terminal.Gui.LayoutTests;
public class DimViewTests
{
[Fact]
public void DimView_Equal ()
{
var view1 = new View ();
var view2 = new View ();
Dim dim1 = Width (view1);
Dim dim2 = Width (view1);
Assert.Equal (dim1, dim2);
dim2 = Width (view2);
Assert.NotEqual (dim1, dim2);
dim2 = Height (view1);
Assert.NotEqual (dim1, dim2);
}
[Fact]
public void DimView_Calculate_ReturnsCorrectValue ()
{
var view = new View { Width = 10 };
view.Layout ();
var dim = new DimView (view, Dimension.Width);
int result = dim.Calculate (0, 100, null, Dimension.None);
Assert.Equal (10, result);
}
// TODO: This actually a SetRelativeLayout/LayoutSubViews test and should be moved
// TODO: A new test that calls SetRelativeLayout directly is needed.
[Fact]
public void Dim_Referencing_SuperView_Does_Not_Throw ()
{
var super = new View { Width = 10, Height = 10, Text = "super" };
var view = new View
{
Width = Width (super), // this is allowed
Height = Height (super), // this is allowed
Text = "view"
};
super.Add (view);
super.BeginInit ();
super.EndInit ();
Exception exception = Record.Exception (super.LayoutSubViews);
Assert.Null (exception);
super.Dispose ();
}
}