Skip to content

Commit

Permalink
add failing unit test to show that TreeDataColumnHeader.ColumnIndex i…
Browse files Browse the repository at this point in the history
…s not kept up to date.
  • Loading branch information
danwalmsley committed Oct 11, 2024
1 parent 09b655b commit fe1a1de
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,35 @@ public void Does_Not_Realize_Columns_Outside_Viewport()
Assert.True(double.IsNaN(columns[3].ActualWidth));
}

[AvaloniaFact(Timeout = 10000)]
public void Header_Column_Indexes_Are_Updated_When_Columns_Are_Updated()
{
var (target, items) = CreateTarget(columns: new IColumn<Model>[]
{
new TextColumn<Model, int>("ID", x => x.Id, width: new GridLength(1, GridUnitType.Star)),
new TextColumn<Model, string?>("Title1", x => x.Title, width: new GridLength(1, GridUnitType.Star)),
new TextColumn<Model, string?>("Title2", x => x.Title, width: new GridLength(1, GridUnitType.Star)),
new TextColumn<Model, string?>("Title3", x => x.Title, width: new GridLength(1, GridUnitType.Star)),
});

AssertColumnIndexes(target, 0, 4);

var source =(FlatTreeDataGridSource<Model>)target.Source!;

var movedColumn = source.Columns[1];
source.Columns.Remove(movedColumn);

AssertColumnIndexes(target, 0, 3);

source.Columns.Add(movedColumn);

var root = (TestWindow)target.GetVisualRoot()!;
root.UpdateLayout();
Dispatcher.UIThread.RunJobs();

AssertColumnIndexes(target, 0, 4);
}

[AvaloniaFact(Timeout = 10000)]
public void Columns_Are_Correctly_Sized_After_Changing_Source()
{
Expand Down

0 comments on commit fe1a1de

Please sign in to comment.