public void DoWithIndexes()
		{
			var source = new[] { new { Property = "First" }, new { Property = "Second" }, new { Property = "Third" } };

			var result = new List<string>();
			source.Do((s, index) => result.Add(index + " - " + s.Property));

			CollectionAssert.AreEqual(new[] { "0 - First", "1 - Second", "2 - Third" }, result);
		}
		public void DoWithNotEmpty()
		{
			var source = new[] { "a1", "a2,", "a3" };
			var result = new List<string>();

			source.Do(s => result.Add(s));

			Assert.AreEqual(source.Length, result.Count);
			Assert.AreEqual(source[0], result[0]);
			Assert.AreEqual(source[1], result[1]);
			Assert.AreEqual(source[2], result[2]);
		}
Example #3
0
		public void Do_on_IEnumerable()
		{
			var source = new[] { "a", "b", "c" };

			var items = new List<string>();
			source.Do(i => { items.Add(i); });

			Assert.AreEqual("a,b,c", String.Join(",", items));
		}