예제 #1
0
        public static void IfCollectionContainsNull <T>(
            [CanBeNull, AssertionCondition(AssertionConditionType.IS_NOT_NULL)]
            IEnumerable <T> collection,
            [NotNull][System.Diagnostics.CodeAnalysis.NotNull] string collectionName
            )
            where T : class
        {
            Fail.RequiresCollectionName(collectionName);

            if (collection == null)
            {
                throw Fail.Because(Violation.WhenCollectionIsNull(collectionName));
            }

            if (collection.Contains(null))
            {
                throw Fail.Because(Violation.WhenCollectionContainsNull(collectionName));
            }
        }