public void ForEach() { var items = new [] {1, 2, 3}; var results = new List<int>(); items.ForEach(results.Add); results .Should("elements should be equal").Have.SameSequenceAs(items); }
public void ForEachWithIndex() { var items = new[] {1, 2, 3}; var resultIndices = new List<int>(); var resultElements = new List<int>(); items.ForEach((o, i) => { resultElements.Add(o); resultIndices.Add(i); }); resultElements.Should().Have.SameSequenceAs(items); resultIndices.Should().Have.SameSequenceAs(new []{0, 1, 2}); }