Пример #1
0
        /// <summary>Verifies an argument is <see langword="null"/>.</summary>
        /// <typeparam name="T">The argument type.</typeparam>
        /// <param name="source">The source.</param>
        /// <param name="message">The message.</param>
        /// <param name="messageArgs">The message arguments.</param>
        /// <returns>The constraint.</returns>
        /// <exception cref="ArgumentException">The argument is not <see langword="null"/>.</exception>
        public static AndArgumentConstraint <T> IsNull <T>(this ArgumentConstraint <T> source, string message, params object[] messageArgs) where T : class
        {
            if (source.Argument.Value != null)
            {
                throw new ArgumentException(String.Format(message, messageArgs), source.Argument.Name);
            }

            return(new AndArgumentConstraint <T>(source));
        }
Пример #2
0
        /// <summary>Verifies an argument is not <see langword="null"/>.</summary>
        /// <typeparam name="T">The argument type.</typeparam>
        /// <param name="source">The source.</param>
        /// <returns>The constraint.</returns>
        /// <exception cref="ArgumentNullException">The argument is <see langword="null"/>.</exception>
        public static AndArgumentConstraint <T> IsNotNull <T>(this ArgumentConstraint <T> source) where T : class
        {
            if (source.Argument.Value == null)
            {
                throw new ArgumentNullException(source.Argument.Name);
            }

            return(new AndArgumentConstraint <T>(source));
        }
Пример #3
0
        /// <summary>Initializes an instance of the <see cref="AndArgumentConstraint{T}"/> class.</summary>
        /// <exception cref="ArgumentNullException"><paramref name="parent"/> is <see langword="null"/>.</exception>
        public AndArgumentConstraint(ArgumentConstraint <T> parent)
        {
            if (parent == null)
            {
                throw new ArgumentNullException("parent");
            }

            m_parent = parent;
        }
Пример #4
0
 /// <summary>Verifies an argument is <see langword="null"/>.</summary>
 /// <typeparam name="T">The argument type.</typeparam>
 /// <param name="source">The source.</param>
 /// <returns>The constraint.</returns>
 /// <exception cref="ArgumentException">The argument is not <see langword="null"/>.</exception>
 public static AndArgumentConstraint <T> IsNull <T>(this ArgumentConstraint <T> source) where T : class
 {
     return(IsNull(source, "Must be null."));
 }