Exemple #1
0
        /// <summary>
        /// Creates a specification that demands that at least one of the
        /// <paramref name="left"/> and <paramref name="right"/> specifications are satisfied.
        /// </summary>
        /// <param name="left">
        /// The left hand side of the operation.
        /// </param>
        /// <param name="right">
        /// The right hand side of the operation
        /// </param>
        /// <typeparam name="T">
        /// The type of entity this specification checks.
        /// </typeparam>
        /// <returns>
        /// An <see cref="ISpecification{T}"/> representing the logical OR operation of the
        /// specifications <paramref name="left"/> and <paramref name="right"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="left"/> or <paramref name="right"/> is null.
        /// </exception>
        public static ISpecification <T> Or <T>(this ISpecification <T> left, ISpecification <T> right)
        {
            RequireThat.NotNull(left, "left");
            RequireThat.NotNull(right, "right");

            return(new OrSpecification <T>(left, right));
        }
Exemple #2
0
 public void WhenNullableWithValue_DoesNotThrow()
 {
     RequireThat.NotNull(new Nullable <int>(1), "name");
 }
Exemple #3
0
 public void WhenNullableWithoutValue_ThrowsException()
 {
     Assert.Throws <ArgumentNullException>(
         () => RequireThat.NotNull(new Nullable <int>(), "name"));
 }
Exemple #4
0
 public void WhenNullNullable_ThrowsException()
 {
     Assert.Throws <ArgumentNullException>(
         () => RequireThat.NotNull(null as int?, "name"));
 }
Exemple #5
0
 public void WhenNonNullObject_DoesNotThrowException()
 {
     RequireThat.NotNull(new object(), "name");
 }
Exemple #6
0
 public void WhenNullObject_ThrowsException()
 {
     Assert.Throws <ArgumentNullException>(
         () => RequireThat.NotNull(null as object, "name"));
 }
Exemple #7
0
        /// <summary>
        /// Creates a specification that demands that the <paramref name="source"/>
        /// specification is not satisfied.
        /// </summary>
        /// <param name="source">
        /// The source specification.
        /// </param>
        /// <typeparam name="T">
        /// The type of entity this specification checks.
        /// </typeparam>
        /// <returns>
        /// An <see cref="ISpecification{T}"/> representing the logical NOT operation of
        /// <paramref name="source"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="source"/> is null.
        /// </exception>
        public static ISpecification <T> Not <T>(this ISpecification <T> source)
        {
            RequireThat.NotNull(source, "source");

            return(new NotSpecification <T>(source));
        }