コード例 #1
0
        public void Moving_Selected_Item_Should_Update_Selection()
        {
            var items = new AvaloniaList <Item>
            {
                new Item(),
                new Item(),
            };

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

            target.ApplyTemplate();
            target.SelectedIndex = 0;

            Assert.Equal(items[0], target.SelectedItem);
            Assert.Equal(0, target.SelectedIndex);

            items.Move(0, 1);

            Assert.Equal(items[1], target.SelectedItem);
            Assert.Equal(1, target.SelectedIndex);
        }
コード例 #2
0
        public void Move_Should_Update_Collection()
        {
            var target = new AvaloniaList <int>(new[] { 1, 2, 3 });

            target.Move(2, 0);

            Assert.Equal(new[] { 3, 1, 2 }, target);
        }
コード例 #3
0
        public void Move_Should_Update_Collection()
        {
            var target = new AvaloniaList<int>(new[] { 1, 2, 3 });

            target.Move(2, 0);

            Assert.Equal(new[] { 3, 1, 2 }, target);
        }
コード例 #4
0
        public void CreateDerivedList_Handles_Move()
        {
            var source = new AvaloniaList <int>(new[] { 0, 1, 2, 3 });
            var target = source.CreateDerivedList(x => new Wrapper(x));

            source.Move(2, 0);

            var result = target.Select(x => x.Value).ToList();

            Assert.Equal(source, result);
        }
コード例 #5
0
        public void Moving_Item_Should_Raise_CollectionChanged()
        {
            var target = new AvaloniaList <int>(new[] { 1, 2, 3 });
            var raised = false;

            target.CollectionChanged += (s, e) =>
            {
                Assert.Equal(target, s);
                Assert.Equal(NotifyCollectionChangedAction.Move, e.Action);
                Assert.Equal(new[] { 3 }, e.OldItems.Cast <int>());
                Assert.Equal(new[] { 3 }, e.NewItems.Cast <int>());
                Assert.Equal(2, e.OldStartingIndex);
                Assert.Equal(0, e.NewStartingIndex);

                raised = true;
            };

            target.Move(2, 0);

            Assert.True(raised);
        }
コード例 #6
0
        public void Moving_Item_Should_Raise_CollectionChanged()
        {
            var target = new AvaloniaList<int>(new[] { 1, 2, 3 });
            var raised = false;

            target.CollectionChanged += (s, e) =>
            {
                Assert.Equal(target, s);
                Assert.Equal(NotifyCollectionChangedAction.Move, e.Action);
                Assert.Equal(new[] { 3 }, e.OldItems.Cast<int>());
                Assert.Equal(new[] { 3 }, e.NewItems.Cast<int>());
                Assert.Equal(2, e.OldStartingIndex);
                Assert.Equal(0, e.NewStartingIndex);

                raised = true;
            };

            target.Move(2, 0);

            Assert.True(raised);
        }