Skip to content

Commit

Permalink
Added version of ListViewItemCollection.AddRange() which accepts IList.
Browse files Browse the repository at this point in the history
  • Loading branch information
AraHaan committed Feb 22, 2024
1 parent 057eeb0 commit 1a905a4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public void AddRange(params ListViewItem[] items)
InnerList.AddRange(items);
}

public void AddRange(ListViewItemCollection items)
public void AddRange(IList items)
{
ArgumentNullException.ThrowIfNull(items);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,24 @@ public void ListViewItemCollection_Find_NullOrEmptyKey_ThrowsArgumentNullExcepti
Assert.Throws<ArgumentNullException>("key", () => collection.Find(key, searchAllSubItems: true));
Assert.Throws<ArgumentNullException>("key", () => collection.Find(key, searchAllSubItems: false));
}

[WinFormsFact]
public void ListViewItemCollection_Given_That_We_Want_To_Use_List_ListViewItem_To_Add_Items()
{
using ListView listView = new();
var list = new List<ListViewItem>();
var keys = new List<string>();
for (var i = 0; i < 10; i++)
{
list.Add(new ListViewItem() { $"item{i}" });
keys.Add($"item{i}");
}

ListView.ListViewItemCollection collection = listView.Items;
collection.AddRange(list);
foreach (var item in list)
{
Asset.Equal(item, collection.Find(key[list.IndexOf(item)], searchAllSubItems: false))l
}
}
}

0 comments on commit 1a905a4

Please sign in to comment.