public override object CreateMock(MockFactory mockFactory, CompositeType typesToMock, string name, MockStyle mockStyle, object[] constructorArgs) { _typesToMock = typesToMock; _typesToMock.Add(typeof(IMockObject)); var reflectiveInterceptor = new ReflectiveInterceptor(mockFactory, typesToMock, name, mockStyle); var proxy = CreateMock(reflectiveInterceptor, constructorArgs); if (_typesToMock.PrimaryType.IsInterface) ((InterfaceMockBase) proxy).Name = name; return proxy; }
public override object CreateMock(MockFactory mockFactory, CompositeType typesToMock, string name, MockStyle mockStyle, object[] constructorArgs) { _typesToMock = typesToMock; _typesToMock.Add(typeof(IMockObject)); var reflectiveInterceptor = new ReflectiveInterceptor(mockFactory, typesToMock, name, mockStyle); var proxy = CreateMock(reflectiveInterceptor, constructorArgs); if (_typesToMock.PrimaryType.IsInterface) { ((InterfaceMockBase)proxy).Name = name; } return(proxy); }
private object CreateMock(ReflectiveInterceptor reflectiveInterceptor, object[] constructorArgs) { var name = new AssemblyName(ASSEMBLY_NAME); #if !SILVERLIGHT _assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(name, AssemblyBuilderAccess.RunAndSave); _moduleBuilder = _assemblyBuilder.DefineDynamicModule(name.Name, name.Name + EXTENSION); #else _assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(name, AssemblyBuilderAccess.Run); _moduleBuilder = _assemblyBuilder.DefineDynamicModule(name.Name); #endif _typeBuilder = GetTypeBuilder(); var type = ImplementType(); //Save(); return(Activator.CreateInstance(type, constructorArgs)); }
private object CreateMock(ReflectiveInterceptor reflectiveInterceptor, object[] constructorArgs) { var name = new AssemblyName(ASSEMBLY_NAME); #if !SILVERLIGHT _assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(name, AssemblyBuilderAccess.RunAndSave); _moduleBuilder = _assemblyBuilder.DefineDynamicModule(name.Name, name.Name + EXTENSION); #else _assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(name, AssemblyBuilderAccess.Run); _moduleBuilder = _assemblyBuilder.DefineDynamicModule(name.Name); #endif _typeBuilder = GetTypeBuilder(); var type = ImplementType(); //Save(); return Activator.CreateInstance(type, constructorArgs); }