Pos.CombineTests.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using Microsoft.VisualStudio.TestPlatform.Utilities;
  2. using UnitTests;
  3. using Xunit.Abstractions;
  4. using static Terminal.Gui.Dim;
  5. using static Terminal.Gui.Pos;
  6. namespace Terminal.Gui.LayoutTests;
  7. public class PosCombineTests (ITestOutputHelper output)
  8. {
  9. private readonly ITestOutputHelper _output = output;
  10. // TODO: This actually a SetRelativeLayout/LayoutSubViews test and should be moved
  11. // TODO: A new test that calls SetRelativeLayout directly is needed.
  12. [Fact]
  13. public void PosCombine_Referencing_Same_View ()
  14. {
  15. var super = new View { Width = 10, Height = 10, Text = "super" };
  16. var view1 = new View { Width = 2, Height = 2, Text = "view1" };
  17. var view2 = new View { Width = 2, Height = 2, Text = "view2" };
  18. view2.X = Pos.AnchorEnd (0) - (Pos.Right (view2) - Pos.Left (view2));
  19. super.Add (view1, view2);
  20. super.BeginInit ();
  21. super.EndInit ();
  22. Exception exception = Record.Exception (super.LayoutSubViews);
  23. Assert.Null (exception);
  24. Assert.Equal (new (0, 0, 10, 10), super.Frame);
  25. Assert.Equal (new (0, 0, 2, 2), view1.Frame);
  26. Assert.Equal (new (8, 0, 2, 2), view2.Frame);
  27. super.Dispose ();
  28. }
  29. }