Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Maupin <ermaup@microsoft.com>2017-12-08 22:36:25 +0300
committerEric Maupin <ermaup@microsoft.com>2017-12-08 22:36:27 +0300
commit78d9d43477840246b95549464454bb22b242c66a (patch)
treef4894abb6d8c01dfa71ca18f3232e39dc2b2ae88 /Xamarin.PropertyEditing.Tests/ObservableLookupTests.cs
parent08cd44b72836c0e5c695f6d8efd5522c65eb4bdf (diff)
[Core] Ignore empty groups
Lookup groups are removed once empty, we shouldn't be adding them if they're empty. This happens when all of a category's properties are removed to form a grouped category, the original category lingered.
Diffstat (limited to 'Xamarin.PropertyEditing.Tests/ObservableLookupTests.cs')
-rw-r--r--Xamarin.PropertyEditing.Tests/ObservableLookupTests.cs51
1 files changed, 50 insertions, 1 deletions
diff --git a/Xamarin.PropertyEditing.Tests/ObservableLookupTests.cs b/Xamarin.PropertyEditing.Tests/ObservableLookupTests.cs
index f88b9b5..0f44768 100644
--- a/Xamarin.PropertyEditing.Tests/ObservableLookupTests.cs
+++ b/Xamarin.PropertyEditing.Tests/ObservableLookupTests.cs
@@ -1,4 +1,5 @@
-using System.Collections.Specialized;
+using System;
+using System.Collections.Specialized;
using System.Linq;
using NUnit.Framework;
@@ -67,5 +68,53 @@ namespace Xamarin.PropertyEditing.Tests
Assert.That (grouping, Does.Not.Contains (value));
Assert.That (lookup, Does.Not.Contain (grouping));
}
+
+ [TestCase ("group")]
+ [TestCase (null)]
+ [Description ("If removing the last item from a group removes the group, adding a group with no items shouldn't add it")]
+ public void AddingEmptyElementsIsIgnored (string groupName)
+ {
+ var lookup = new ObservableLookup<string, string> ();
+ bool changed = false;
+ lookup.CollectionChanged += (sender, args) => {
+ changed = true;
+ };
+ lookup.Add (groupName, Enumerable.Empty<string> ());
+
+ Assert.That (lookup, Is.Empty);
+ Assert.That (changed, Is.False);
+ }
+
+ [TestCase ("group")]
+ [TestCase (null)]
+ [Description ("If removing the last item from a group removes the group, adding a group with no items shouldn't add it")]
+ public void AddingEmptyGroupingIsIgnored (string groupName)
+ {
+ var lookup = new ObservableLookup<string, string> ();
+ bool changed = false;
+ lookup.CollectionChanged += (sender, args) => {
+ changed = true;
+ };
+ lookup.Add (new ObservableGrouping<string, string> (groupName));
+
+ Assert.That (lookup, Is.Empty);
+ Assert.That (changed, Is.False);
+ }
+
+ [TestCase ("group")]
+ [TestCase (null)]
+ [Description ("If removing the last item from a group removes the group, adding a group with no items shouldn't add it")]
+ public void InsertingEmptyIsIgnored (string groupName)
+ {
+ var lookup = new ObservableLookup<string, string> ();
+ bool changed = false;
+ lookup.CollectionChanged += (sender, args) => {
+ changed = true;
+ };
+ lookup.Insert (0, new ObservableGrouping<string, string> (groupName));
+
+ Assert.That (lookup, Is.Empty);
+ Assert.That (changed, Is.False);
+ }
}
}