Skip to content

Commit f4a638b

Browse files
authored
shortcut for iitem (#883)
* shortcut for iitem * syntax guard
1 parent 0c324ef commit f4a638b

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/KubernetesClient.Models/IItems.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,12 @@ public interface IItems<T>
1212
/// </summary>
1313
IList<T> Items { get; set; }
1414
}
15+
16+
public static class ItemsExt
17+
{
18+
public static IEnumerator<T> GetEnumerator<T>(this IItems<T> items)
19+
{
20+
return items.Items.GetEnumerator();
21+
}
22+
}
1523
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using Xunit;
2+
using k8s.Models;
3+
4+
namespace k8s.Tests;
5+
6+
public class ItemsEnumTests
7+
{
8+
[Fact]
9+
public void EnsureIItemsEnumerable()
10+
{
11+
var pods = new V1PodList
12+
{
13+
Items = new[] { new V1Pod() },
14+
};
15+
16+
// ensure no sytax err
17+
foreach (var pod in pods)
18+
{
19+
Assert.NotNull(pod);
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)