Add test for empty ListContainer (#11297)

This commit is contained in:
Jacob Tong
2022-09-16 04:11:34 -07:00
committed by GitHub
parent 62260da16b
commit 2003a58138

View File

@@ -48,6 +48,32 @@ public sealed class ListContainerTest : RobustUnitTest
Assert.That(children[1].Position.Y, Is.EqualTo(13)); // Item height + separation
}
[Test]
public void TestCreatePopulateAndEmpty()
{
const int x = 50;
const int y = 10;
var root = new Control { MinSize = (x, y) };
var listContainer = new ListContainer { SeparationOverride = 3 };
root.AddChild(listContainer);
listContainer.GenerateItem += (_, button) => {
button.AddChild(new Control { MinSize = (10, 10) });
};
var list = new List<TestListData>();
listContainer.PopulateList(list);
root.Arrange(new UIBox2(0, 0, x, y));
list.Add(new(0));
list.Add(new (1));
listContainer.PopulateList(list);
root.Arrange(new UIBox2(0, 0, x, y));
list.Clear();
listContainer.PopulateList(list);
root.Arrange(new UIBox2(0, 0, x, y));
}
[Test]
public void TestOnlyVisibleItemsAreAdded()
{