Browse Source

Added some failing tests.

That demonstrate some problems with the `SelectionModel` change notifications found so far.
pull/3498/head
Steven Kirk 6 years ago
parent
commit
2336f85d02
  1. 32
      tests/Avalonia.Controls.UnitTests/SelectionModelTests.cs

32
tests/Avalonia.Controls.UnitTests/SelectionModelTests.cs

@ -1360,6 +1360,38 @@ namespace Avalonia.Controls.UnitTests
Assert.Equal(3, target.SelectedItems.Count); Assert.Equal(3, target.SelectedItems.Count);
} }
[Fact]
public void Not_Enumerating_Changes_Does_Not_Prevent_Further_Operations()
{
var data = new[] { "foo", "bar", "baz" };
var target = new SelectionModel { Source = data };
target.SelectionChanged += (s, e) => { };
target.SelectAll();
target.ClearSelection();
}
[Fact]
public void Can_Change_Selection_From_SelectionChanged()
{
var data = new[] { "foo", "bar", "baz" };
var target = new SelectionModel { Source = data };
var raised = 0;
target.SelectionChanged += (s, e) =>
{
if (raised++ == 0)
{
target.ClearSelection();
}
};
target.SelectAll();
Assert.Equal(2, raised);
}
private int GetSubscriberCount(AvaloniaList<object> list) private int GetSubscriberCount(AvaloniaList<object> list)
{ {
return ((INotifyCollectionChangedDebug)list).GetCollectionChangedSubscribers()?.Length ?? 0; return ((INotifyCollectionChangedDebug)list).GetCollectionChangedSubscribers()?.Length ?? 0;

Loading…
Cancel
Save