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); }
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); }
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); }
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); }
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); }
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); }