public static void Returns_false_when_actual_count_is_lower_than_expected_min_count_with_predicate() { IEnumerable<string> fruits = new[] { "apple", "apricot", "banana" }; fruits.HasAtLeast(3, fruit => fruit.StartsWith("a")).Should().BeFalse(); fruits.HasAtLeast(2, fruit => fruit.StartsWith("b")).Should().BeFalse(); }
public static void Returns_true_when_actual_count_is_greater_than_or_equal_to_expected_min_count_with_predicate() { IEnumerable<string> fruits = new[] { "apple", "apricot", "banana" }; IEnumerable<string> emptySequence = Enumerable.Empty<string>(); fruits.HasAtLeast(1, fruit => fruit.StartsWith("a")).Should().BeTrue(); fruits.HasAtLeast(2, fruit => fruit.StartsWith("a")).Should().BeTrue(); fruits.HasAtLeast(1, fruit => fruit.StartsWith("b")).Should().BeTrue(); emptySequence.HasAtLeast(0, _ => true).Should().BeTrue(); }
public void HasAtLeast() { var emptyCollection = new int[] { }; Assert.IsTrue(emptyCollection.HasAtLeast(0)); Assert.IsFalse(emptyCollection.HasAtLeast(1)); var unaryCollection = new[] { 0 }; Assert.IsTrue(unaryCollection.HasAtLeast(0)); Assert.IsTrue(unaryCollection.HasAtLeast(1)); Assert.IsFalse(unaryCollection.HasAtLeast(2)); var arrayCollection = new[] { 0, 1, 2, 3 }; Assert.IsTrue(arrayCollection.HasAtLeast(0)); Assert.IsTrue(arrayCollection.HasAtLeast(1)); Assert.IsTrue(arrayCollection.HasAtLeast(2)); Assert.IsTrue(arrayCollection.HasAtLeast(3)); Assert.IsTrue(arrayCollection.HasAtLeast(4)); Assert.IsFalse(arrayCollection.HasAtLeast(5)); Assert.IsTrue(Enumerable.Empty<int>().HasAtLeast(0)); Assert.IsFalse(Enumerable.Empty<int>().HasAtLeast(1)); Assert.IsTrue(Enumerable.Range(0, 1).HasAtLeast(0)); Assert.IsTrue(Enumerable.Range(0, 1).HasAtLeast(1)); Assert.IsFalse(Enumerable.Range(0, 1).HasAtLeast(2)); Assert.IsTrue(Enumerable.Range(0, 4).HasAtLeast(0)); Assert.IsTrue(Enumerable.Range(0, 4).HasAtLeast(1)); Assert.IsTrue(Enumerable.Range(0, 4).HasAtLeast(2)); Assert.IsTrue(Enumerable.Range(0, 4).HasAtLeast(3)); Assert.IsTrue(Enumerable.Range(0, 4).HasAtLeast(4)); Assert.IsFalse(Enumerable.Range(0, 4).HasAtLeast(5)); }