|
|
|
@ -541,6 +541,35 @@ namespace Avalonia.Controls.UnitTests.Primitives |
|
|
|
Assert.True(called); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Replacing_SelectedItems_Should_Raise_SelectionChanged_With_CorrectItems() |
|
|
|
{ |
|
|
|
var items = new[] { "foo", "bar", "baz" }; |
|
|
|
|
|
|
|
var target = new TestSelector |
|
|
|
{ |
|
|
|
Items = items, |
|
|
|
Template = Template(), |
|
|
|
SelectedItem = "bar", |
|
|
|
}; |
|
|
|
|
|
|
|
var called = false; |
|
|
|
|
|
|
|
target.SelectionChanged += (s, e) => |
|
|
|
{ |
|
|
|
Assert.Equal(new[] { "foo",}, e.AddedItems.Cast<object>()); |
|
|
|
Assert.Equal(new[] { "bar" }, e.RemovedItems.Cast<object>()); |
|
|
|
called = true; |
|
|
|
}; |
|
|
|
|
|
|
|
target.ApplyTemplate(); |
|
|
|
target.Presenter.ApplyTemplate(); |
|
|
|
target.SelectedItems[0] = "foo"; |
|
|
|
|
|
|
|
Assert.True(called); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private FuncControlTemplate Template() |
|
|
|
{ |
|
|
|
return new FuncControlTemplate<SelectingItemsControl>(control => |
|
|
|
|