예제 #1
0
        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);
        }
예제 #2
0
        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});
        }