예제 #1
0
        /// <summary>
        ///     Checks that the string contains the given expected values, in any order.
        /// </summary>
        /// <param name="check">The fluent check to be extended.</param>
        /// <param name="values">The expected values to be found.</param>
        /// <returns>
        ///     A check link.
        /// </returns>
        /// <exception cref="FluentCheckException">The string  contains all the given strings in any order.</exception>
        public static IExtendableCheckLink <string, string[]> Contains(this ICheck <string> check, params string[] values)
        {
            var block = ExtensibilityHelper.BeginCheck(check);

            ContainsLogic(values, block);
            return(ExtensibilityHelper.BuildExtendableCheckLink(check, values));
        }
예제 #2
0
 /// <summary>
 /// Checks that the enumerable contains all the given expected values, in any order.
 /// </summary>
 /// <typeparam name="T">Type of the elements contained in the enumerable.</typeparam>
 /// <param name="check">The fluent check to be extended.</param>
 /// <param name="expectedValues">The expected values to be found.</param>
 /// <returns>
 ///  A check link.
 /// </returns>
 /// <exception cref="FluentCheckException">The enumerable does not contain all the expected values.</exception>
 public static ExtendableCheckLink <ICheck <IEnumerable <T> >, IEnumerable <T> > Contains <T>(
     this ICheck <IEnumerable <T> > check,
     IEnumerable <T> expectedValues)
 {
     ImplementContains(ExtensibilityHelper.BeginCheck(check), expectedValues);
     return(ExtensibilityHelper.BuildExtendableCheckLink(check, expectedValues));
 }
예제 #3
0
        /// <summary>
        /// Checks that the enumerable contains all the given expected values, in any order.
        /// </summary>
        /// <typeparam name="T">Type of the elements contained in the enumerable.</typeparam>
        /// <param name="check">The fluent check to be extended.</param>
        /// <param name="expectedValues">The expected values to be found.</param>
        /// <returns>
        ///  A check link.
        /// </returns>
        /// <exception cref="FluentCheckException">The enumerable does not contain all the expected values.</exception>
        public static ExtendableCheckLink <ICheck <IEnumerable <T> >, IEnumerable <T> > Contains <T>(
            this ICheck <IEnumerable <T> > check,
            params T[] expectedValues)
        {
            var properExpectedValues = ExtractEnumerableValueFromPossibleOneValueArray(expectedValues);

            ImplementContains(ExtensibilityHelper.BeginCheck(check), properExpectedValues);
            return(ExtensibilityHelper.BuildExtendableCheckLink(check, properExpectedValues));
        }
예제 #4
0
        /// <summary>
        /// Checks that the enumerable contains all the values present in another enumerable, in any order.
        /// </summary>
        /// <param name="check">The fluent check to be extended.</param>
        /// <param name="otherEnumerable">The enumerable containing the expected values to be found.</param>
        /// <returns>
        /// A check link.
        /// </returns>
        /// <exception cref="FluentCheckException">
        /// The enumerable does not contain all the expected values present in the other enumerable.
        /// </exception>
        public static ExtendableCheckLink <ICheck <IEnumerable>, IEnumerable> Contains(
            this ICheck <IEnumerable> check, params object[] otherEnumerable)
        {
            var properExpectedValues = ExtractEnumerableValueFromSingleEntry(otherEnumerable).Cast <object>();
            var checker = ExtensibilityHelper.BeginCheckAs(check, enumerable => enumerable.Cast <object>());

            ImplementContains(checker, properExpectedValues);

            return(ExtensibilityHelper.BuildExtendableCheckLink(check, (IEnumerable)properExpectedValues));
        }
예제 #5
0
        /// <summary>
        /// Checks that the enumerable contains all the values present in another enumerable, in any order.
        /// </summary>
        /// <param name="check">The fluent check to be extended.</param>
        /// <param name="otherEnumerable">The enumerable containing the expected values to be found.</param>
        /// <returns>
        /// A check link.
        /// </returns>
        /// <exception cref="FluentCheckException">
        /// The enumerable does not contain all the expected values present in the other enumerable.
        /// </exception>
        public static IExtendableCheckLink <IEnumerable, IEnumerable> Contains(
            this ICheck <IEnumerable> check,
            IEnumerable otherEnumerable)
        {
            IList <object> notFoundValues = null;

            ExtensibilityHelper.BeginCheck(check).
            FailsIf((sut) => sut == null && otherEnumerable != null, "The {0} is null and thus, does not contain the given expected value(s).").
            ExpectingValues(otherEnumerable, otherEnumerable.Count()).
            Analyze((sut, _) => notFoundValues = ExtractNotFoundValues(sut, otherEnumerable)).
            FailsIf((_) => notFoundValues.Any(), string.Format(
                        "The {{0}} does not contain the expected value(s):" + Environment.NewLine + "\t[{0}]", notFoundValues.ToEnumeratedString().DoubleCurlyBraces())).
            Negates("The {0} contains all the given values whereas it must not.").
            EndCheck();

            return(ExtensibilityHelper.BuildExtendableCheckLink(check, otherEnumerable));
        }