feat(*): Add WithIndex IEnumerable extension

This commit is contained in:
Josh Creek
2021-08-27 00:35:18 +01:00
parent 06c6057876
commit 3a63fca25b
4 changed files with 69 additions and 1 deletions
+35
View File
@@ -0,0 +1,35 @@
using NUnit.Framework;
using Creek.HelpfulExtensions;
using System.Collections.Generic;
namespace UnitTests
{
public class IEnumerableExtensionTests
{
[SetUp]
public void Setup()
{
}
[Test]
public void IsSubstringBetweenFirst()
{
List<int> list = new List<int>()
{
1,2,3,4,5,6,7,8,9
};
string indexString = string.Empty;
string valueString = string.Empty;
foreach (var (item, index) in list.WithIndex())
{
indexString += index;
valueString += item;
}
Assert.AreEqual("012345678", indexString);
Assert.AreEqual("123456789", valueString);
}
}
}