public void Any_When_null_It_throws_ArgumentNullException()
        {
            int[]            values    = null;
            Func <int, bool> predicate = i => i == 0;

            AssertIsNotNull(
                () => Ensure.Enumerable.HasAny(values, predicate, ParamName),
                () => EnsureArg.HasAny(values, predicate, ParamName),
                () => Ensure.That(values, ParamName).HasAny(predicate));
        }
Пример #2
0
        public void HasAny_When_IDictionary_is_null_It_throws_ArgumentNullException()
        {
            IDictionary <int, int> values = null;
            Func <KeyValuePair <int, int>, bool> predicate = i => i.Value == 0;

            AssertIsNotNull(
                () => Ensure.Collection.HasAny(values, predicate, ParamName),
                () => EnsureArg.HasAny(values, predicate, ParamName),
                () => Ensure.That(values, ParamName).HasAny(predicate));
        }
Пример #3
0
        public void HasAny_When_IList_is_null_It_throws_ArgumentNullException()
        {
            IList <int>      values    = null;
            Func <int, bool> predicate = i => i == 0;

            AssertIsNotNull(
                () => Ensure.Collection.HasAny(values, predicate, ParamName),
                () => EnsureArg.HasAny(values, predicate, ParamName),
                () => Ensure.That(values, ParamName).HasAny(predicate));
        }
Пример #4
0
        public void HasAny_When_Array_predicate_yields_something_It_should_not_throw()
        {
            var values = new[] { 1, 2, 3, 4 };
            Func <int, bool> predicate = i => i == 1;

            ShouldNotThrow(
                () => Ensure.Collection.HasAny(values, predicate, ParamName),
                () => EnsureArg.HasAny(values, predicate, ParamName),
                () => Ensure.That(values, ParamName).HasAny(predicate));
        }
Пример #5
0
        public void HasAny_When_Array_predicate_yields_none_It_throws_ArgumentException()
        {
            var values = new[] { 1, 2, 3, 4 };
            Func <int, bool> predicate = i => i == 0;

            AssertAnyPredicateYieldedNone(
                () => Ensure.Collection.HasAny(values, predicate, ParamName),
                () => EnsureArg.HasAny(values, predicate, ParamName),
                () => Ensure.That(values, ParamName).HasAny(predicate));
        }
        public void Any_When_predicate_yields_none_It_throws_ArgumentException()
        {
            IList <int> values = new List <int> {
                1, 2, 3, 4
            };
            Func <int, bool> predicate = i => i == 0;

            AssertAnyPredicateYieldedNone(
                () => Ensure.Enumerable.HasAny(values, predicate, ParamName),
                () => EnsureArg.HasAny(values, predicate, ParamName),
                () => Ensure.That(values, ParamName).HasAny(predicate));
        }