public void CountReturnNumberOfElementsThatMatchThePredicate() { var values = new[] { 1, 2, 3 }; Assert.AreEqual(2, values.Count(v => v >= 2)); }
public void CountReturnNumberOfElementsWhenNoPredicateIsDefined() { var values = new[] { 1, 2, 3 }; Assert.AreEqual(3, values.Count()); }
public void AnyReturnsTrueWhenAllElementsMatchThePredicate() { var values = new[] { 1, 2, 3 }; Assert.IsTrue(values.Any(v => v > 0)); }
public void AnyReturnsTrueWhenAtLeastOneElementMatchesThePredicate() { var values = new[] { 1, 2, 3 }; Assert.IsTrue(values.Any(v => v >= 3)); }
public void AnyReturnsFalseNoElementMatchesThePredicate() { var values = new[] { 1, 2, 3 }; Assert.IsFalse(values.Any(v => v == 4)); }
public void AllReturnsTrueWhenAllElementMatchThePredicate() { var values = new[] { 1, 2, 3 }; Assert.IsTrue(values.All(v => v < 4)); }
public void AllReturnsFalseWhenAtLeastOneElementDoesNotMatchThePredicate() { var values = new[] { 1, 2, 3 }; Assert.IsFalse(values.All(v => v < 3)); }
public void ElementAtReturnsElementAtTheSpecifiedIndex() { var values = new[] { 1, 2, 3 }; Assert.AreEqual(2, values.ElementAt(1)); }
static void Main(string[] args) { Linq.Demonstrate(); }