Explorar o código

Add additional failing test for #4654.

Steven Kirk %!s(int64=5) %!d(string=hai) anos
pai
achega
f4017162cd
Modificáronse 1 ficheiros con 30 adicións e 2 borrados
  1. 30 2
      tests/Avalonia.Controls.UnitTests/TabControlTests.cs

+ 30 - 2
tests/Avalonia.Controls.UnitTests/TabControlTests.cs

@@ -174,6 +174,36 @@ namespace Avalonia.Controls.UnitTests
             Assert.Equal(collection[0].Content, target.SelectedContent);
         }
 
+        [Fact]
+        public void Removal_Should_Set_New_Item0_When_Item0_Selected_With_DataTemplate()
+        {
+            using var app = UnitTestApplication.Start(TestServices.StyledWindow);
+
+            var collection = new ObservableCollection<Item>()
+            {
+                new Item("first"),
+                new Item("second"),
+                new Item("3rd"),
+            };
+
+            var target = new TabControl
+            {
+                Template = TabControlTemplate(),
+                Items = collection,
+            };
+
+            Prepare(target);
+            target.SelectedItem = collection[0];
+
+            Assert.Same(collection[0], target.SelectedItem);
+            Assert.Equal(collection[0], target.SelectedContent);
+
+            collection.RemoveAt(0);
+
+            Assert.Same(collection[0], target.SelectedItem);
+            Assert.Equal(collection[0], target.SelectedContent);
+        }
+
         [Fact]
         public void TabItem_Templates_Should_Be_Set_Before_TabItem_ApplyTemplate()
         {
@@ -394,8 +424,6 @@ namespace Avalonia.Controls.UnitTests
             }
         }
 
-
-
         private IControlTemplate TabControlTemplate()
         {
             return new FuncControlTemplate<TabControl>((parent, scope) =>