diff --git a/tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs b/tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs index 7d3c1fe4f4..f8ba4bd5fc 100644 --- a/tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs +++ b/tests/Avalonia.Controls.UnitTests/ItemsControlTests.cs @@ -513,6 +513,41 @@ namespace Avalonia.Controls.UnitTests Assert.Same(before, after); } + [Fact] + public void Control_Item_Should_Be_Removed_From_LogicalChildren() + { + using var app = Start(); + var item = new Border(); + + var items = new ObservableCollection(); + var target = CreateTarget(itemsSource: items); + + items.Add(item); + items.Remove(item); + + Assert.Empty(target.LogicalChildren); + } + + [Fact] + public void Control_Item_Should_Be_Removed_From_LogicalChildren_Virtualizing() + { + using var app = Start(); + var item = new Border(); + + var items = new ObservableCollection(); + var itemsPanel = new FuncTemplate(() => new VirtualizingStackPanel()); + var target = CreateTarget( + itemsPanel: itemsPanel, + itemsSource: items); + + items.Add(item); + Layout(target); + + items.Remove(item); + + Assert.Empty(target.LogicalChildren); + } + [Fact] public void Should_Clear_Containers_When_ItemsPresenter_Changes() {