mirror of
https://github.com/jcreek/Creek.HelpfulExtensions.git
synced 2026-07-13 03:03:45 +00:00
feat(*): Add WithIndex IEnumerable extension
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user