Example #1
0
        /// <summary>
        /// Creates a mocked instance of the given type which implements
        /// the collection of types
        /// </summary>
        /// <remarks>
        /// Applicable for Partial mocks
        /// </remarks>
        /// <typeparam name="T">the type to mock</typeparam>
        /// <param name="extraTypes">array of types implemented by the type</param>
        /// <param name="arguments">constructor arguments</param>
        /// <returns>a mocked instance of the given type</returns>
        public static T MockMulti <T>(Type[] extraTypes, params object[] arguments)
            where T : class
        {
            var type       = typeof(T);
            var remoteType = typeof(MarshalByRefObject);

            var repository = new MockRepository();

            if (remoteType.IsAssignableFrom(type))
            {
                if (arguments == null || arguments.Length == 0)
                {
                    return((T)repository.CreateMockRemoted(type));
                }
            }

            return(repository.CreateMockObject <T>(extraTypes, arguments));
        }