Browse Source

Added another failing test.

Adapted from failing test described by @MarchingCube in PR feedback: https://github.com/AvaloniaUI/Avalonia/pull/3177#issuecomment-547515972
Steven Kirk 6 years ago
parent
commit
9107c0e96e
1 changed files with 23 additions and 0 deletions
  1. 23 0
      tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs

+ 23 - 0
tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs

@@ -12,6 +12,7 @@ using Xunit;
 using System.Collections.ObjectModel;
 using Avalonia.UnitTests;
 using Avalonia.Input;
+using System.Collections.Generic;
 
 namespace Avalonia.Controls.UnitTests
 {
@@ -104,6 +105,28 @@ namespace Avalonia.Controls.UnitTests
             Assert.Equal(new[] { child }, target.GetLogicalChildren());
         }
 
+        [Fact]
+        public void Added_Container_Should_Have_LogicalParent_Set_To_ItemsControl()
+        {
+            var item = new Border();
+            var items = new ObservableCollection<Border>();
+
+            var target = new ItemsControl
+            {
+                Template = GetTemplate(),
+                Items = items,
+            };
+
+            var root = new TestRoot(true, target);
+
+            root.Measure(new Size(100, 100));
+            root.Arrange(new Rect(0, 0, 100, 100));
+
+            items.Add(item);
+
+            Assert.Equal(target, item.Parent);
+        }
+
         [Fact]
         public void Control_Item_Should_Be_Removed_From_Logical_Children_Before_ApplyTemplate()
         {