Skip to content

Commit

Permalink
Added another failing test for #4496.
Browse files Browse the repository at this point in the history
  • Loading branch information
grokys committed Aug 17, 2020
1 parent 05e0f00 commit e4e4004
Showing 1 changed file with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ public void Removing_Item_Before_SelectedItem_Should_Update_SelectedIndex()
[Fact]
public void Removing_Item_Before_SelectedItem_Should_Update_Container_Selection_When_SelectionModel_Present()
{
// Issue #4496.
// Issue #4496 (part 1).
var items = new ObservableCollection<string>
{
"Foo",
Expand Down Expand Up @@ -1121,6 +1121,34 @@ public void Removing_Item_Before_SelectedItem_Should_Update_Container_Selection_
Assert.True(container.IsSelected);
}

[Fact]
public void Binding_SelectedIndex_Does_Not_Cause_ArgumentOutOfRange()
{
// Issue #4496 (part 2)
var items = new ObservableCollection<string>();

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");
}

[Fact]
public void Replacing_Selected_Item_Should_Update_SelectedItem()
{
Expand Down

0 comments on commit e4e4004

Please sign in to comment.