Skip to content

Commit

Permalink
Add tests for case where Expander column is removed or a second is ad…
Browse files Browse the repository at this point in the history
…ded.
  • Loading branch information
danwalmsley committed Oct 11, 2024
1 parent 04f57cc commit 0565c43
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,6 @@ private void OnColumnsCollectionChanged(object? sender, NotifyCollectionChangedE
{
throw new InvalidOperationException("The expander column cannot be removed by a reset.");
}

_expanderColumn = null; // Optionally clear the expander column
break;

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,36 @@ public void CollapseAll_Collapses_All_Rows(bool sorted)
}
}

[AvaloniaFact(Timeout = 10000)]
public void Adding_Second_Expander_Column_Throws()
{
var data = CreateData();
var target = CreateTarget(data, false);

Assert.Throws<InvalidOperationException>(() =>
{
target.Columns.Add(new HierarchicalExpanderColumn<Node>(
new TextColumn<Node, int>("ID", x => x.Id),
x => x.Children,
null,
x => x.IsExpanded));
});
}

[AvaloniaFact(Timeout = 10000)]
public void Removing_Expander_Column_Throws()
{
var data = CreateData();
var target = CreateTarget(data, false);

var expander = target.Columns.OfType<IExpanderColumn<Node>>().First();

Assert.Throws<InvalidOperationException>(() =>
{
target.Columns.Remove(expander);
});
}

public class ExpansionBinding
{
[AvaloniaFact(Timeout = 10000)]
Expand Down

0 comments on commit 0565c43

Please sign in to comment.