Skip to content

Commit

Permalink
shortcut for iitem (#883)
Browse files Browse the repository at this point in the history
* shortcut for iitem

* syntax guard
  • Loading branch information
tg123 authored Sep 21, 2022
1 parent 0c324ef commit f4a638b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/KubernetesClient.Models/IItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@ public interface IItems<T>
/// </summary>
IList<T> Items { get; set; }
}

public static class ItemsExt
{
public static IEnumerator<T> GetEnumerator<T>(this IItems<T> items)
{
return items.Items.GetEnumerator();
}
}
}
22 changes: 22 additions & 0 deletions tests/KubernetesClient.Tests/ItemsEnumTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Xunit;
using k8s.Models;

namespace k8s.Tests;

public class ItemsEnumTests
{
[Fact]
public void EnsureIItemsEnumerable()
{
var pods = new V1PodList
{
Items = new[] { new V1Pod() },
};

// ensure no sytax err
foreach (var pod in pods)
{
Assert.NotNull(pod);
}
}
}

0 comments on commit f4a638b

Please sign in to comment.