Ejemplo n.º 1
0
        /// <summary>
        /// Similiar to <see cref="ListArg{T}.Equal"/> but without considering the order of the elements in the collection.
        /// </summary>
        public static T[] Equivalent <T> (this ListArg <IEnumerable <T> > arg, params T[] items)
        {
            var argManagerType = typeof(ListArg <>).Assembly.GetType("Rhino.Mocks.ArgManager", true);
            var message        = "equivalent to collection [" + string.Join(", ", items) + "]";
            var constraint     = new PredicateConstraintWithMessage <IEnumerable <T> > (c => c.SetEquals(items), message);

            PrivateInvoke.InvokeNonPublicStaticMethod(argManagerType, "AddInArgument", constraint);

            return(new T[0]);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Similiar to <see cref="ListArg{T}.Equal"/> but without considering the order of the elements in the collection.
        /// </summary>
        public static T Equivalent <T> (this ListArg <T> arg, IEnumerable collection) where T : IEnumerable
        {
            var items      = collection.Cast <object>().ToArray();
            var type       = typeof(ListArg <>).Assembly.GetType("Rhino.Mocks.ArgManager", true);
            var message    = "equivalent to collection [" + string.Join(", ", (IEnumerable <object>)items) + "]";
            var constraint = new PredicateConstraintWithMessage <T> (c => c.Cast <object>().SetEquals(items), message);

            PrivateInvoke.InvokeNonPublicStaticMethod(type, "AddInArgument", constraint);
            return(default(T));
        }