private static long Signature(IEnumerable <int> list) { var val = 0L; var indexedSequence = CollConv.ToIndexedSequence(list); foreach (var pair in indexedSequence) { val += (pair.Key + 1) * pair.Value; } return(val); }
public void EnumeratorToEnumerableAfterTest() { var source = new List <string> { "1", "2", "3", "4", "5" }; using var enumerator = source.GetEnumerator(); var target = CollConv.ToEnumerableAfter(enumerator); var targetList = target.ToList(); targetList.ShouldNotBeNull(); targetList.Count.ShouldBe(6); targetList[0].ShouldBe(default);
public void EnumeratorToEnumerableTest() { var source = new List <string> { "1", "2", "3", "4", "5" }; using var enumerator = source.GetEnumerator(); var target = CollConv.ToEnumerable(enumerator); var targetList = target.ToList(); targetList.ShouldNotBeNull(); targetList.Count.ShouldBe(5); targetList[0].ShouldBe("1"); targetList[1].ShouldBe("2"); targetList[2].ShouldBe("3"); targetList[3].ShouldBe("4"); targetList[4].ShouldBe("5"); }