1
0
Steven Kirk 7 жил өмнө
parent
commit
9c1c8749dd

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

@@ -315,6 +315,26 @@ namespace Avalonia.Controls.UnitTests
             Assert.Same(before, after);
         }
 
+        [Fact]
+        public void Should_Clear_Containers_When_ItemsPresenter_Changes()
+        {
+            var target = new ItemsControl
+            {
+                Items = new[] { "foo", "bar" },
+                Template = GetTemplate(),
+            };
+
+            target.ApplyTemplate();
+            target.Presenter.ApplyTemplate();
+
+            Assert.Equal(2, target.ItemContainerGenerator.Containers.Count());
+
+            target.Template = GetTemplate();
+            target.ApplyTemplate();
+
+            Assert.Empty(target.ItemContainerGenerator.Containers);
+        }
+
         [Fact]
         public void Empty_Class_Should_Initially_Be_Applied()
         {