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-11 19:30:39 +0300
committerAlan McGovern <alanmcgovern@users.noreply.github.com>2019-02-11 19:30:39 +0300
commite35b493b34e6f1a21eb0e1c1866eee7eb57823ed (patch)
tree8472355d4ed8627d3ab60b4425f26bb8707e6f49 /Xamarin.PropertyEditing.Tests
parent938859ba86e47f72259609267cb094dde88ac72e (diff)
Revert "Grouped type fixes" (#527)
PR526 introduced a crash in named arrange mode and exposed a hole in our tests. All tests pass, but no properties are shown in either mode.
Diffstat (limited to 'Xamarin.PropertyEditing.Tests')
-rw-r--r--Xamarin.PropertyEditing.Tests/PanelViewModelTests.cs172
1 files changed, 1 insertions, 171 deletions
diff --git a/Xamarin.PropertyEditing.Tests/PanelViewModelTests.cs b/Xamarin.PropertyEditing.Tests/PanelViewModelTests.cs
index 9c1a7db..0626626 100644
--- a/Xamarin.PropertyEditing.Tests/PanelViewModelTests.cs
+++ b/Xamarin.PropertyEditing.Tests/PanelViewModelTests.cs
@@ -209,7 +209,7 @@ namespace Xamarin.PropertyEditing.Tests
[Test]
public async Task PropertyListCategoryGroupedWithNullCategory ()
{
- // Purposefully a null category
+ // Purposefully a null catgory
var normalProp = new Mock<IPropertyInfo> ();
normalProp.SetupGet (p => p.Type).Returns (typeof(string));
normalProp.SetupGet (p => p.Name).Returns ("name");
@@ -414,176 +414,6 @@ namespace Xamarin.PropertyEditing.Tests
Assert.That (vm.GetIsExpanded (normalProp.Object.Category), Is.True);
}
- [Test]
- public void GroupedTypesDoNotLeavePhantomCategory ()
- {
- var target = new object ();
-
- var property = new Mock<IPropertyInfo> ();
- property.SetupGet (p => p.Type).Returns (typeof (string));
- property.SetupGet (p => p.Category).Returns ((string)null);
- property.SetupGet (p => p.Name).Returns ("name");
-
- var provider = new Mock<IEditorProvider> ();
- provider.Setup (ep => ep.GetObjectEditorAsync (target))
- .ReturnsAsync (new MockObjectEditor (property.Object) { Target = target });
-
- var platform = new TargetPlatform (provider.Object) {
- GroupedTypes = new Dictionary<Type, string> {
- { typeof(string), "strings" }
- }
- };
-
- var vm = CreateVm (platform);
- vm.ArrangeMode = PropertyArrangeMode.Category;
- vm.AutoExpand = true;
- vm.SelectedObjects.Add (target);
-
- Assert.That (vm.ArrangedEditors.Count, Is.EqualTo (1));
- }
-
- [Test]
- [Description ("https://github.com/xamarin/Xamarin.PropertyEditing/issues/525")]
- public void SwitchingFromObjectWithGroupedType ()
- {
- var targetWithProperties = new object ();
- var targetWithoutProperties = new object ();
-
- var property = new Mock<IPropertyInfo> ();
- property.SetupGet (p => p.Type).Returns (typeof (string));
- property.SetupGet (p => p.Category).Returns ((string)null);
- property.SetupGet (p => p.Name).Returns ("name");
-
- var property2 = new Mock<IPropertyInfo> ();
- property2.SetupGet (p => p.Type).Returns (typeof (string));
- property2.SetupGet (p => p.Category).Returns ((string)null);
- property2.SetupGet (p => p.Name).Returns ("name2");
-
- var provider = new Mock<IEditorProvider> ();
- provider.Setup (ep => ep.GetObjectEditorAsync (targetWithProperties))
- .ReturnsAsync (new MockObjectEditor (property.Object, property2.Object) { Target = targetWithProperties });
- provider.Setup (ep => ep.GetObjectEditorAsync (targetWithoutProperties))
- .ReturnsAsync (new MockObjectEditor (new IPropertyInfo[0]) { Target = targetWithoutProperties });
-
- var platform = new TargetPlatform (provider.Object) {
- GroupedTypes = new Dictionary<Type, string> {
- { typeof(string), "strings" }
- }
- };
-
- var vm = CreateVm (platform);
- vm.ArrangeMode = PropertyArrangeMode.Category;
- vm.AutoExpand = true;
- vm.SelectedObjects.Add (targetWithProperties);
-
- Assume.That (vm.ArrangedEditors.Count, Is.EqualTo (1));
-
- Assert.That (() => vm.SelectedObjects.ReplaceOrAdd (targetWithProperties, targetWithoutProperties),
- Throws.Nothing);
- Assert.That (vm.ArrangedEditors.Count, Is.EqualTo (0));
- }
-
- [Test]
- public void SwitchingToObjectWithGroupedType ()
- {
- var targetWithProperties = new object ();
- var targetWithoutProperties = new object ();
-
- var property = new Mock<IPropertyInfo> ();
- property.SetupGet (p => p.Type).Returns (typeof (string));
- property.SetupGet (p => p.Category).Returns ((string)null);
- property.SetupGet (p => p.Name).Returns ("name");
-
- var property2 = new Mock<IPropertyInfo> ();
- property2.SetupGet (p => p.Type).Returns (typeof (string));
- property2.SetupGet (p => p.Category).Returns ((string)null);
- property2.SetupGet (p => p.Name).Returns ("name2");
-
- var provider = new Mock<IEditorProvider> ();
- provider.Setup (ep => ep.GetObjectEditorAsync (targetWithProperties))
- .ReturnsAsync (new MockObjectEditor (property.Object, property2.Object) { Target = targetWithProperties });
- provider.Setup (ep => ep.GetObjectEditorAsync (targetWithoutProperties))
- .ReturnsAsync (new MockObjectEditor (new IPropertyInfo[0]) { Target = targetWithoutProperties });
-
- var platform = new TargetPlatform (provider.Object) {
- GroupedTypes = new Dictionary<Type, string> {
- { typeof(string), "strings" }
- }
- };
-
- var vm = CreateVm (platform);
- vm.ArrangeMode = PropertyArrangeMode.Category;
- vm.AutoExpand = true;
- vm.SelectedObjects.Add (targetWithoutProperties);
-
- Assume.That (vm.ArrangedEditors.Count, Is.EqualTo (0));
-
- Assert.That (() => vm.SelectedObjects.ReplaceOrAdd (targetWithoutProperties, targetWithProperties),
- Throws.Nothing);
- Assert.That (vm.ArrangedEditors.Count, Is.EqualTo (1));
-
- var group = vm.ArrangedEditors[0].Editors[0] as PropertyGroupViewModel;
- Assert.That (group, Is.Not.Null);
- Assert.That (group.Properties.Count, Is.EqualTo (2));
- }
-
- [Test]
- public void GroupedTypeMultiselect ()
- {
- var outer = new object ();
- var inner = new object ();
-
- var property = new Mock<IPropertyInfo> ();
- property.SetupGet (p => p.Type).Returns (typeof (string));
- property.SetupGet (p => p.Category).Returns ((string)null);
- property.SetupGet (p => p.Name).Returns ("name");
-
- var property2 = new Mock<IPropertyInfo> ();
- property2.SetupGet (p => p.Type).Returns (typeof (string));
- property2.SetupGet (p => p.Category).Returns ((string)null);
- property2.SetupGet (p => p.Name).Returns ("name2");
-
- var provider = new Mock<IEditorProvider> ();
- provider.Setup (ep => ep.GetObjectEditorAsync (outer))
- .ReturnsAsync (new MockObjectEditor (property.Object, property2.Object) { Target = outer });
- provider.Setup (ep => ep.GetObjectEditorAsync (inner))
- .ReturnsAsync (new MockObjectEditor (property.Object) { Target = inner });
-
- var platform = new TargetPlatform (provider.Object) {
- GroupedTypes = new Dictionary<Type, string> {
- { typeof(string), "strings" }
- }
- };
-
- var vm = CreateVm (platform);
- vm.ArrangeMode = PropertyArrangeMode.Category;
- vm.AutoExpand = true;
- vm.SelectedObjects.Add (outer);
-
- Assume.That (vm.ArrangedEditors.Count, Is.EqualTo (1));
-
- var group = vm.ArrangedEditors[0].Editors[0] as PropertyGroupViewModel;
- Assume.That (group, Is.Not.Null);
- Assume.That (group.Properties.Count, Is.EqualTo (2));
-
- bool shouldChange = false, changed = false;
- if (group.Properties is INotifyCollectionChanged incc) {
- shouldChange = true;
- incc.CollectionChanged += (o, e) => changed = true;
- }
-
- vm.SelectedObjects.Add (inner);
- Assert.That (vm.ArrangedEditors[0].Editors[0] as PropertyGroupViewModel, Is.SameAs (group));
- Assert.That (group.Properties.Count, Is.EqualTo (1), "Number of remaining properties isn't correct");
- Assert.That (group.Properties[0].Property, Is.EqualTo (property.Object), "Wrong property found in the group");
- Assert.That (changed, Is.EqualTo (shouldChange), "Changed status didn't match expected");
-
- vm.SelectedObjects.Remove (inner);
- group = vm.ArrangedEditors[0].Editors[0] as PropertyGroupViewModel;
- Assert.That (group, Is.Not.Null);
- Assert.That (group.Properties.Count, Is.EqualTo (2), "Outer properties didn't restore");
- }
-
internal override PanelViewModel CreateVm (TargetPlatform platform)
{
return new PanelViewModel (platform);