private static void Test_ToEnumerable_Implementation(ListItemCollection listItemCollection) { var enumerable = listItemCollection.ToEnumerable(); Assert.IsAssignableFrom <IEnumerable <ListItem> >(enumerable); foreach (var x in enumerable) { Assert.IsType <ListItem>(x); } }
public static void Test_ToEnumerable() { var listItemCollection = new ListItemCollection(); Assert.Empty(listItemCollection); Test_ToEnumerable_Implementation(listItemCollection); listItemCollection.AddRange(new[] { new ListItem("Hello"), new ListItem("Hello", "World"), new ListItem("Test", "Test") }); Test_ToEnumerable_Implementation(listItemCollection); listItemCollection.Add(new ListItem("Extra")); Test_ToEnumerable_Implementation(listItemCollection); Assert.Equal(2, listItemCollection.ToEnumerable().Count(x => x.Text == "Hello")); Assert.Equal(1, listItemCollection.ToEnumerable().Count(x => x.Value == "Extra")); Assert.Equal(0, listItemCollection.ToEnumerable().Count(x => x.Value == "Missing")); Assert.Equal(2, listItemCollection.ToEnumerable().Count(x => x.Text.Contains('t'))); }