Exemplo n.º 1
0
        public void FuzzyFilter()
        {
            var tests     = new StringViewModelTests();
            var mproperty = tests.GetPropertyMock("Property");

            var target    = new object();
            var resource  = new Resource <string> (MockResourceProvider.SystemResourcesSource, "@android:string/foo_bar", "value");
            var resource2 = new Resource <string> (MockResourceProvider.SystemResourcesSource, "@android:string/foo_baz", "value");

            var mprovider = new Mock <IResourceProvider>();

            mprovider.Setup(r => r.GetResourcesAsync(target, mproperty.Object, CancellationToken.None)).ReturnsAsync(new[] { resource, resource2 });

            var vm = new ResourceSelectorViewModel(mprovider.Object, new[] { target }, mproperty.Object);

            Assume.That(vm.Resources, Contains.Item(resource));
            Assume.That(vm.Resources, Contains.Item(resource2));

            vm.FilterText = "baz";
            Assert.That(vm.Resources, Does.Not.Contain(resource));
            Assert.That(vm.Resources, Contains.Item(resource2));

            vm.FilterText = "string";
            Assert.That(vm.Resources, Contains.Item(resource));
            Assert.That(vm.Resources, Contains.Item(resource2));
        }
Exemplo n.º 2
0
        public void FilterGroupableWhenNotGrouped()
        {
            var stringProvider = new StringViewModelTests();

            var stringProperty1 = stringProvider.GetPropertyMock("string1");
            var stringProperty2 = stringProvider.GetPropertyMock("string2");

            var editor = new MockObjectEditor(stringProperty1.Object, stringProperty2.Object);

            var provider = new Mock <IEditorProvider> ();

            provider.Setup(p => p.GetObjectEditorAsync(editor.Target)).ReturnsAsync(editor);

            var platform = new TargetPlatform(provider.Object)
            {
                GroupedTypes = new Dictionary <Type, string> {
                    { typeof(string), "B" }
                }
            };

            var vm = new PanelViewModel(platform);

            Assume.That(vm.ArrangeMode, Is.EqualTo(PropertyArrangeMode.Name));
            vm.SelectedObjects.Add(editor.Target);
            Assume.That(vm.ArrangedEditors[0].Editors.Count, Is.EqualTo(2));

            vm.FilterText = "A";
            Assert.That(vm.ArrangedEditors.Count, Is.EqualTo(0));
        }
Exemplo n.º 3
0
        public void GroupedPropertiesArrange()
        {
            var intProvider    = new IntegerPropertyViewModelTests();
            var stringProvider = new StringViewModelTests();
            var brushProvider  = new SolidBrushPropertyViewModelTests();

            var intProperty     = intProvider.GetPropertyMock("int", "A");
            var stringProperty1 = stringProvider.GetPropertyMock("string1");
            var stringProperty2 = stringProvider.GetPropertyMock("string2");
            var brushProperty   = brushProvider.GetPropertyMock("brush", "C");

            var editor = new MockObjectEditor(intProperty.Object, stringProperty1.Object, stringProperty2.Object, brushProperty.Object);

            var provider = new Mock <IEditorProvider> ();

            provider.Setup(p => p.GetObjectEditorAsync(editor.Target)).ReturnsAsync(editor);

            var platform = new TargetPlatform(provider.Object)
            {
                GroupedTypes = new Dictionary <Type, string> {
                    { typeof(string), "B" }
                }
            };

            var vm = new PanelViewModel(platform);

            Assume.That(vm.ArrangeMode, Is.EqualTo(PropertyArrangeMode.Name));

            vm.ArrangeMode = PropertyArrangeMode.Category;
            vm.SelectedObjects.Add(editor.Target);
            Assert.That(vm.ArrangedEditors[0].Category, Is.EqualTo("A"));
            Assert.That(vm.ArrangedEditors[1].Category, Is.EqualTo("B"));
            Assert.That(vm.ArrangedEditors[2].Category, Is.EqualTo("C"));
        }
Exemplo n.º 4
0
        public void Resources()
        {
            var tests     = new StringViewModelTests();
            var mproperty = tests.GetPropertyMock("Property");

            object target = new object();

            var resource  = new Resource <string> (MockResourceProvider.SystemResourcesSource, "Resource", "value");
            var mprovider = new Mock <IResourceProvider>();

            mprovider.Setup(r => r.GetResourcesAsync(target, mproperty.Object, CancellationToken.None)).ReturnsAsync(new[] { resource });

            var vm = new ResourceSelectorViewModel(mprovider.Object, new[] { target }, mproperty.Object);

            Assert.That(vm.Resources, Contains.Item(resource));
        }