/// <summary> /// Matches any value that is not found in the sequence specified. /// </summary> /// <param name="items">The sequence of disallowed values.</param> /// <param name="comparer">An <see cref="IEqualityComparer{T}"/> with which the values should be compared.</param> /// <typeparam name="TValue">Type of the argument to check.</typeparam> public static TValue IsNotIn <TValue>( IEnumerable <TValue> items, IEqualityComparer <TValue> comparer ) { return(Match <TValue> .Create( value => !items.Contains(value, comparer), () => It.IsNotIn(items, comparer) )); }
/// <summary> /// Matches any value that is not found in the sequence specified. /// </summary> /// <param name="items">The sequence of disallowed values.</param> /// <typeparam name="TValue">Type of the argument to check.</typeparam> /// <example> /// The following example shows how to expect a method call with an integer argument /// of any value except 1, 2, or 3. /// <code> /// mock.Setup(x => x.HasInventory( /// It.IsAny<string>(), /// It.IsNotIn(1, 2, 3))) /// .Returns(false); /// </code> /// </example> public static TValue IsNotIn <TValue>(params TValue[] items) { return(Match <TValue> .Create(value => !items.Contains(value), () => It.IsNotIn(items))); }
/// <summary> /// Matches any value that is not found in the sequence specified. /// </summary> /// <param name="items">The sequence of disallowed values.</param> /// <typeparam name="TValue">Type of the argument to check.</typeparam> /// <example> /// The following example shows how to expect a method call with an integer argument /// with value not found from a list. /// <code> /// var values = new List<int> { 1, 2, 3 }; /// /// mock.Setup(x => x.HasInventory( /// It.IsAny<string>(), /// It.IsNotIn(values))) /// .Returns(false); /// </code> /// </example> public static TValue IsNotIn <TValue>(IEnumerable <TValue> items) { return(Match <TValue> .Create(value => !items.Contains(value), () => It.IsNotIn(items))); }