浏览代码

Added tests to test new fn; which isn't implemented yet, so they fail.

Tig 1 年之前
父节点
当前提交
671a18f1b5
共有 1 个文件被更改,包括 30 次插入0 次删除
  1. 30 0
      UnitTests/View/Layout/AnchorEndTests.cs

+ 30 - 0
UnitTests/View/Layout/AnchorEndTests.cs

@@ -84,6 +84,8 @@ public class AnchorEndTests (ITestOutputHelper output)
     [InlineData (1, 10, 24)]
     [InlineData (1, 10, 24)]
     [InlineData (10, 10, 15)]
     [InlineData (10, 10, 15)]
     [InlineData (20, 10, 5)]
     [InlineData (20, 10, 5)]
+    [InlineData (25, 10, 0)]
+    [InlineData (26, 10, -1)]
     public void AnchorEnd_With_Offset_PositionsViewOffsetFromRight (int offset, int width, int expectedXPosition)
     public void AnchorEnd_With_Offset_PositionsViewOffsetFromRight (int offset, int width, int expectedXPosition)
     {
     {
         // Arrange
         // Arrange
@@ -105,6 +107,34 @@ public class AnchorEndTests (ITestOutputHelper output)
         Assert.Equal (expectedXPosition, view.Frame.X);
         Assert.Equal (expectedXPosition, view.Frame.X);
     }
     }
 
 
+    [Theory]
+    [InlineData (0, 25)]
+    [InlineData (10, 15)]
+    [InlineData (9, 16)]
+    [InlineData (11, 14)]
+    [InlineData (25, 0)]
+    [InlineData (26, -1)]
+    public void AnchorEnd_No_Offset_PositionsViewOffsetByWidth (int width, int expectedXPosition)
+    {
+        // Arrange
+        var superView = new View { Width = 25, Height = 25 };
+        var view = new View
+        {
+            X = Pos.AnchorEnd (),
+            Width = width,
+            Height = 1
+        };
+        superView.Add (view);
+        superView.BeginInit ();
+        superView.EndInit ();
+
+        // Act
+        superView.LayoutSubviews ();
+
+        // Assert
+        Assert.Equal (expectedXPosition, view.Frame.X);
+    }
+
     // This test used to be Dialog_In_Window_With_TextField_And_Button_AnchorEnd in DialogTests.
     // This test used to be Dialog_In_Window_With_TextField_And_Button_AnchorEnd in DialogTests.
     [Fact]
     [Fact]
     [SetupFakeDriver]
     [SetupFakeDriver]