Browse Source

Failing unit tests #3180

Benedikt Schroeder 6 years ago
parent
commit
4d14218a65
1 changed files with 26 additions and 0 deletions
  1. 26 0
      tests/Avalonia.Controls.UnitTests/TabControlTests.cs

+ 26 - 0
tests/Avalonia.Controls.UnitTests/TabControlTests.cs

@@ -4,6 +4,7 @@
 using System;
 using System.Collections.ObjectModel;
 using System.Linq;
+using Avalonia.Collections;
 using Avalonia.Controls.Presenters;
 using Avalonia.Controls.Primitives;
 using Avalonia.Controls.Templates;
@@ -44,6 +45,31 @@ namespace Avalonia.Controls.UnitTests
             Assert.Equal(selected, target.SelectedItem);
         }
 
+        [Fact]
+        public void Pre_Selecting_TabItem_Should_Set_SelectedContent_After_It_Was_Added()
+        {
+            var target = new TabControl
+            {
+                Template = TabControlTemplate(),
+            };
+
+            const string secondContent = "Second";
+
+            var items = new AvaloniaList<object>
+            {
+                new TabItem { Header = "First"},
+                new TabItem { Header = "Second", Content = secondContent, IsSelected = true }
+            };
+
+            target.Items = items;
+
+            target.ApplyTemplate();
+
+            target.Measure(Size.Infinity);
+
+            Assert.Equal(secondContent, target.SelectedContent);
+        }
+
         [Fact]
         public void Logical_Children_Should_Be_TabItems()
         {