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 <me@ermau.com>2019-02-26 22:02:26 +0300
committerGitHub <noreply@github.com>2019-02-26 22:02:26 +0300
commit94afbbdb281b229ee35f6d119c856dc84a7aeea8 (patch)
treef8d6bfa22ae212047176ffbfdfd9b924c5c3e414 /Xamarin.PropertyEditing.Tests
parent5e9aefc24f558f731c327b48febb7c76b53317d3 (diff)
parent4a2adca8b44173dc9c141b25d40c87fc7b36d75b (diff)
Merge pull request #538 from xamarin/ermau-type-selector-fixes
Object editor / type selector fixes
Diffstat (limited to 'Xamarin.PropertyEditing.Tests')
-rw-r--r--Xamarin.PropertyEditing.Tests/ObjectPropertyViewModelTests.cs35
-rw-r--r--Xamarin.PropertyEditing.Tests/SimpleCollectionViewTests.cs44
2 files changed, 79 insertions, 0 deletions
diff --git a/Xamarin.PropertyEditing.Tests/ObjectPropertyViewModelTests.cs b/Xamarin.PropertyEditing.Tests/ObjectPropertyViewModelTests.cs
index ef3e438..cedf835 100644
--- a/Xamarin.PropertyEditing.Tests/ObjectPropertyViewModelTests.cs
+++ b/Xamarin.PropertyEditing.Tests/ObjectPropertyViewModelTests.cs
@@ -256,6 +256,41 @@ namespace Xamarin.PropertyEditing.Tests
Assert.That (vm.ValueType, Is.Null);
}
+ [Test]
+ public void ReturnedNullTypeCancels ()
+ {
+ object value = new object ();
+ var p = CreatePropertyMock ("prop");
+ var childsubInfo = GetTypeInfo (typeof (SubChildClass));
+ var editor = new MockObjectEditor (new[] { p.Object }, new Dictionary<IPropertyInfo, IReadOnlyList<ITypeInfo>> {
+ {
+ p.Object,
+ new[] {
+ GetTypeInfo (typeof(ChildClass)),
+ childsubInfo
+ }
+ }
+ });
+
+ var providerMock = CreateProviderMock (value, new MockObjectEditor { Target = value });
+ var vm = new ObjectPropertyViewModel (new TargetPlatform (providerMock.Object), p.Object, new[] { editor });
+
+ var tcs = new TaskCompletionSource<ITypeInfo> ();
+ bool requested = false;
+ vm.TypeRequested += (sender, args) => {
+ requested = true;
+ args.SelectedType = tcs.Task;
+ };
+
+ Assume.That (vm.CreateInstanceCommand.CanExecute (childsubInfo), Is.True);
+ vm.CreateInstanceCommand.Execute (null);
+ Assume.That (requested, Is.True);
+
+ tcs.SetResult (null);
+
+ providerMock.Verify (ep => ep.CreateObjectAsync (null), Times.Never);
+ }
+
private TestContext syncContext;
private Mock<IEditorProvider> CreateProviderMock (object value, IObjectEditor editor)
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;