diff options
author | Eric Maupin <ermaup@microsoft.com> | 2019-02-20 23:30:42 +0300 |
---|---|---|
committer | Eric Maupin <ermaup@microsoft.com> | 2019-02-20 23:30:45 +0300 |
commit | 4a2adca8b44173dc9c141b25d40c87fc7b36d75b (patch) | |
tree | 2d20e258f8f79d9bb6a7149e639045d0d35c1d7d /Xamarin.PropertyEditing.Tests | |
parent | 20394cf6c9d2706da77425753a1e70d1fe4f1a89 (diff) |
[core] Fix empty parents on filter changes
Fixes #522
Diffstat (limited to 'Xamarin.PropertyEditing.Tests')
-rw-r--r-- | Xamarin.PropertyEditing.Tests/SimpleCollectionViewTests.cs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Xamarin.PropertyEditing.Tests/SimpleCollectionViewTests.cs b/Xamarin.PropertyEditing.Tests/SimpleCollectionViewTests.cs index 1a54640..cb13ad8 100644 --- a/Xamarin.PropertyEditing.Tests/SimpleCollectionViewTests.cs +++ b/Xamarin.PropertyEditing.Tests/SimpleCollectionViewTests.cs @@ -756,6 +756,50 @@ namespace Xamarin.PropertyEditing.Tests Assert.Throws<ArgumentOutOfRangeException> (() => view[2].ToString(), "this[] didn't throw out of range on filtered out item"); } + [Test] + [Description ("Covers #522, empty parents now unfiltered by their own filter shouldn't be added")] + public void ParentFilterChangesOnEmpty () + { + var parents = new ObservableCollection<TestNode> { + new TestNode ("A") { + Children = new List<TestNode> { + new TestNode ("A child") + } + }, + new TestNode ("Baz") { + Children = new List<TestNode> { + new TestNode ("Baz child") + } + }, + new TestNode ("Bar") { + Children = new List<TestNode> { + new TestNode ("Bar child") + } + }, + }; + + var view = new SimpleCollectionView (parents, new SimpleCollectionViewOptions { + DisplaySelector = TestNodeDisplaySelector, + ChildrenSelector = TestNodeChildrenSelector, + ChildOptions = new SimpleCollectionViewOptions { + DisplaySelector = TestNodeDisplaySelector + } + }); + + Assume.That (view.Count, Is.EqualTo (3)); + + view.Options.Filter = o => ((TestNode) o).Key != "Bar"; + Assume.That (view.Count, Is.EqualTo (2)); + + view.Options.ChildOptions.Filter = o => ((TestNode) o).Key.StartsWith ("A"); + Assume.That (view.Count, Is.EqualTo (1)); + + view.Options.Filter = null; + + Assert.That (((KeyValuePair<string, SimpleCollectionView>) view[0]).Key, Is.EqualTo (parents[0].Key)); + Assert.That (view.Count, Is.EqualTo (1)); + } + private IEnumerable TestNodeChildrenSelector (object o) { return ((TestNode)o).Children; |