/// <summary> /// Creates a mocked instance of the given type which implements /// the collection of types targeting classes with abstract or virtual members /// </summary> /// <typeparam name="T">the class 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 PartialMulti <T>(Type[] extraTypes, params object[] arguments) where T : class { if (extraTypes.Any(x => !x.IsInterface)) { throw new ArgumentException("Additional types to be implemented for a mocked object must be interfaces.", "extraTypes"); } var type = typeof(T); if (type.IsInterface) { throw new InvalidOperationException("Interfaces cannot be used to create a Partial mock."); } var repository = new MockRepository(); return(repository.CreateMockClass(type, extraTypes, arguments, true) as T); }