示例#1
0
        public void Assigning_Selection_Should_Set_Item_IsSelected()
        {
            var items = new[]
            {
                new ListBoxItem(),
                new ListBoxItem(),
                new ListBoxItem(),
            };

            var target = new TestSelector
            {
                Items    = items,
                Template = Template(),
            };

            target.ApplyTemplate();
            target.Presenter.ApplyTemplate();

            var selection = new SelectionModel {
                Source = items
            };

            selection.SelectRange(new IndexPath(0), new IndexPath(1));
            target.Selection = selection;

            Assert.True(items[0].IsSelected);
            Assert.True(items[1].IsSelected);
            Assert.False(items[2].IsSelected);
        }
示例#2
0
        private static SelectedItemsSync CreateTarget(
            IEnumerable <string> items = null)
        {
            items ??= new[] { "foo", "bar", "baz" };

            var model = new SelectionModel {
                Source = items
            };

            model.SelectRange(new IndexPath(1), new IndexPath(2));

            var target = new SelectedItemsSync(model);

            return(target);
        }
示例#3
0
        private static SelectedItemsSync CreateTarget(
            IEnumerable <string> items = null)
        {
            items ??= new[] { "foo", "bar", "baz" };

            var model = new SelectionModel <string> {
                Source = items, SingleSelect = false
            };

            model.SelectRange(1, 2);

            var target = new SelectedItemsSync(model);

            return(target);
        }
示例#4
0
        public void Assigning_Multiple_Selected_Items_To_Selection_Should_Set_SelectedIndex()
        {
            var target = new TestSelector
            {
                Items    = new[] { "foo", "bar", "baz" },
                Template = Template(),
            };

            target.ApplyTemplate();
            target.Presenter.ApplyTemplate();

            var selection = new SelectionModel {
                Source = target.Items
            };

            selection.SelectRange(new IndexPath(0), new IndexPath(2));
            target.Selection = selection;

            Assert.Equal(0, target.SelectedIndex);
            Assert.Equal(new[] { "foo", "bar", "baz" }, target.Selection.SelectedItems);
            Assert.Equal(new[] { 0, 1, 2 }, SelectedContainers(target));
        }