예제 #1
0
		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;
		}
예제 #2
0
        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);
        }
예제 #3
0
        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));
        }
예제 #4
0
		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);
		}