/// <summary> /// Matches any value that is present in the sequence specified. /// </summary> /// <param name="items">The sequence of possible 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 IsIn <TValue>(IEnumerable <TValue> items, IEqualityComparer <TValue> comparer) { return(Match <TValue> .Create(value => items.Contains(value, comparer), () => It.IsIn(items, comparer))); }
/// <summary> /// Matches any value that is present in the sequence specified. /// </summary> /// <param name="items">The sequence of possible 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 a value of 1, 2, or 3. /// <code> /// mock.Setup(x => x.HasInventory( /// It.IsAny<string>(), /// It.IsIn(1, 2, 3))) /// .Returns(false); /// </code> /// </example> public static TValue IsIn <TValue>(params TValue[] items) { return(Match <TValue> .Create(value => items.Contains(value), () => It.IsIn(items))); }
/// <summary> /// Matches any value that is present in the sequence specified. /// </summary> /// <param name="items">The sequence of possible 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 from a list. /// <code> /// var values = new List<int> { 1, 2, 3 }; /// /// mock.Setup(x => x.HasInventory( /// It.IsAny<string>(), /// It.IsIn(values))) /// .Returns(false); /// </code> /// </example> public static TValue IsIn <TValue>(IEnumerable <TValue> items) { return(Match <TValue> .Create(value => items.Contains(value), () => It.IsIn(items))); }