From c2a142745890250ee7bc307c79d4a9e9c722af43 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Wed, 19 Aug 2020 16:56:55 +0200 Subject: [PATCH] Added skipped tests for #4496. --- .../Primitives/SelectingItemsControlTests.cs | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests.cs b/tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests.cs index 320f660a8f8..4ad384b0544 100644 --- a/tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests.cs +++ b/tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests.cs @@ -1089,6 +1089,68 @@ public void Removing_Item_Before_SelectedItem_Should_Update_SelectedIndex() Assert.Equal("Bar", target.SelectedItem); } + [Fact(Skip = "We don't handle this properly yet")] + public void Binding_SelectedIndex_Selects_Correct_Item() + { + // Issue #4496 (part 2) + var items = new ObservableCollection(); + + var other = new ListBox + { + Template = Template(), + Items = items, + SelectionMode = SelectionMode.AlwaysSelected, + }; + + var target = new ListBox + { + Template = Template(), + Items = items, + [!ListBox.SelectedIndexProperty] = other[!ListBox.SelectedIndexProperty], + }; + + target.ApplyTemplate(); + target.Presenter.ApplyTemplate(); + other.ApplyTemplate(); + other.Presenter.ApplyTemplate(); + + items.Add("Foo"); + + Assert.Equal(0, other.SelectedIndex); + Assert.Equal(0, target.SelectedIndex); + } + + [Fact(Skip = "We don't handle this properly yet")] + public void Binding_SelectedItem_Selects_Correct_Item() + { + // Issue #4496 (part 2) + var items = new ObservableCollection(); + + var other = new ListBox + { + Template = Template(), + Items = items, + SelectionMode = SelectionMode.AlwaysSelected, + }; + + var target = new ListBox + { + Template = Template(), + Items = items, + [!ListBox.SelectedItemProperty] = other[!ListBox.SelectedItemProperty], + }; + + target.ApplyTemplate(); + target.Presenter.ApplyTemplate(); + other.ApplyTemplate(); + other.Presenter.ApplyTemplate(); + + items.Add("Foo"); + + Assert.Equal(0, other.SelectedIndex); + Assert.Equal(0, target.SelectedIndex); + } + [Fact] public void Replacing_Selected_Item_Should_Update_SelectedItem() {