Browse Source

Added failing test for #1709.

Steven Kirk 7 years ago
parent
commit
9c1c8749dd
1 changed files with 20 additions and 0 deletions
  1. 20 0
      tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs

+ 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()
         {