Esempio n. 1
0
        /// <summary>
        ///     Checks that the enumerable contains only the values of another enumerable and nothing else, in order.
        ///     This check should only be used with IEnumerable that have a consistent iteration order
        ///     (i.e. don't use it with Hashtable, prefer <see cref="IsEquivalentTo" /> in that case).
        /// </summary>
        /// <param name="check">The fluent check to be extended.</param>
        /// <param name="otherEnumerable">The other enumerable containing the exact expected values to be found.</param>
        /// <returns>
        ///     A check link.
        /// </returns>
        /// <exception cref="FluentCheckException">
        ///     The enumerable does not contains only the exact given values and nothing else,
        ///     in order.
        /// </exception>
        public static ICheckLink <ICheck <IEnumerable> > ContainsExactly(
            this ICheck <IEnumerable> check, params object[] otherEnumerable)
        {
            var properExpectedValues = ExtractEnumerableValueFromSingleEntry(otherEnumerable).Cast <object>();

            ImplementContainsExactly(ExtensibilityHelper.BeginCheckAs(check, u => u.Cast <object>()), properExpectedValues);
            return(ExtensibilityHelper.BuildCheckLink(check));
        }
        /// <summary>
        /// Checks that the checked <see cref="IEnumerable"/> contains items in the expected order.
        /// </summary>
        /// <param name="check">
        /// The chained fluent check.
        /// </param>
        /// <returns>
        /// A check link.
        /// </returns>
        public static IExtendableCheckLink <ICheck <IEnumerable>, IEnumerable> InThatOrder(this IExtendableCheckLink <ICheck <IEnumerable>, IEnumerable> check)
        {
            var orderedList = new List <object>(check.OriginalComparand.Cast <object>());
            var checker     = ExtensibilityHelper.BeginCheckAs(check.AccessCheck, enumerable => enumerable.Cast <object>());

            ImplementInThatOrder(checker, orderedList);
            return(check);
        }
Esempio n. 3
0
        /// <summary>
        /// Checks if the sut contains the same element than a given list.
        /// </summary>
        /// <param name="context">Context for the check</param>
        /// <param name="expectedValues">Expected values</param>
        /// <returns>A chainable link.</returns>
        public static ICheckLink <ICheck <IEnumerable> > IsEquivalentTo(this ICheck <IEnumerable> context,
                                                                        params object[] expectedValues)
        {
            var content = ExtractEnumerableValueFromPossibleOneValueArray(expectedValues);

            ImplementEquivalentTo(ExtensibilityHelper.BeginCheckAs(context, enumerable => enumerable.Cast <object>()), content);
            return(ExtensibilityHelper.BuildCheckLink(context));
        }
        /// <summary>
        /// Checks that the checked <see cref="IEnumerable"/> contains the expected list of items only once.
        /// </summary>
        /// <param name="check">
        /// The chained fluent check.
        /// </param>
        /// <returns> bv
        /// A check link.
        /// </returns>
        public static ExtendableCheckLink <ICheck <IEnumerable>, IEnumerable> Once(this ExtendableCheckLink <ICheck <IEnumerable>, IEnumerable> check)
        {
            IExtendableCheckLink <ICheck <IEnumerable>, IEnumerable> chainedCheckLink = check;

            ImplementOnce(
                ExtensibilityHelper.BeginCheckAs(chainedCheckLink.AccessCheck, enumerable => enumerable.Cast <object>()),
                chainedCheckLink.OriginalComparand.Cast <object>());
            return(check);
        }
Esempio n. 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 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));
        }
Esempio n. 6
0
        /// <summary>
        ///     Checks that the enumerable contains only the given values and nothing else, in any order.
        ///     Note: this check succeeded with empty value.
        /// </summary>
        /// <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 only the expected values provided.</exception>
        public static ICheckLink <ICheck <IEnumerable> > IsOnlyMadeOf(
            this ICheck <IEnumerable> check,
            params object[] expectedValues)
        {
            var properExpectedValues = ExtractEnumerableValueFromSingleEntry(expectedValues);

            ImplementIsOnlyMadeOf(ExtensibilityHelper.BeginCheckAs(check, enumerable => enumerable.Cast <object>()), properExpectedValues);

            return(ExtensibilityHelper.BuildCheckLink(check));
        }
Esempio n. 7
0
 /// <summary>
 /// Checks if the sut contains the same element than a given list.
 /// </summary>
 /// <param name="context">Context for the check</param>
 /// <param name="content"></param>
 /// <returns>A chainable link.</returns>
 public static ICheckLink <ICheck <IEnumerable> > IsEquivalentTo(this ICheck <IEnumerable> context,
                                                                 params object[] content)
 {
     ImplementEquivalentTo(ExtensibilityHelper.BeginCheckAs(context, enumerable => enumerable.Cast <object>()), content);
     return(ExtensibilityHelper.BuildCheckLink(context));
 }