public void SetUp() { _innerMock = MockRepository.GenerateStrictMock <IMethodBaseBuilder> (); _operandProvider = MockRepository.GenerateStrictMock <IEmittableOperandProvider> (); _decorator = MockRepository.GeneratePartialMock <MethodBaseBuilderDecoratorBase> (_innerMock, _operandProvider); }
private void DefineParameters(IMethodBaseBuilder methodBaseBuilder, IMutableMethodBase mutableMethodBase) { foreach (var parameter in mutableMethodBase.MutableParameters) { DefineParameter(methodBaseBuilder, parameter); } }
private IParameterBuilder SetupDefineParameter( IMethodBaseBuilder methodBaseBuilderMock, int position, string parameterName, ParameterAttributes parameterAttributes) { var parameterBuilderMock = MockRepository.GenerateStrictMock <IParameterBuilder>(); methodBaseBuilderMock.Expect(mock => mock.DefineParameter(position, parameterAttributes, parameterName)).Return(parameterBuilderMock); return(parameterBuilderMock); }
private Action CreateBodyBuildAction( CodeGenerationContext context, IMethodBaseBuilder methodBuilder, IEnumerable <ParameterExpression> parameterExpressions, Expression unpreparedBody) { // Bodies need to be generated after all other members have been declared (to allow bodies to reference new members). return(() => { var body = _expressionPreparer.PrepareBody(context, unpreparedBody); var bodyLambda = Expression.Lambda(body, parameterExpressions); methodBuilder.SetBody(bodyLambda, _ilGeneratorFactory, context.DebugInfoGenerator); }); }
private void CheckBodyBuildAction(Action testedAction, IMethodBaseBuilder methodBuilderMock, IMutableMethodBase mutableMethodBase) { methodBuilderMock.BackToRecord(); _expressionPreparerMock.Expect(mock => mock.PrepareBody(_context, mutableMethodBase.Body)).Return(_fakeBody); methodBuilderMock .Expect(mock => mock.SetBody(Arg <LambdaExpression> .Is.Anything, Arg.Is(_ilGeneratorFactoryStub), Arg.Is(_context.DebugInfoGenerator))) .WhenCalled( mi => { var lambdaExpression = (LambdaExpression)mi.Arguments[0]; Assert.That(lambdaExpression.Body, Is.SameAs(_fakeBody)); Assert.That(lambdaExpression.Parameters, Is.EqualTo(mutableMethodBase.ParameterExpressions)); }); methodBuilderMock.Replay(); testedAction(); _emittableOperandProviderMock.VerifyAllExpectations(); methodBuilderMock.VerifyAllExpectations(); }
protected MethodBaseBuilderDecoratorBase(IMethodBaseBuilder methodBaseBuilder, IEmittableOperandProvider emittableOperandProvider) : base(methodBaseBuilder, emittableOperandProvider) { _methodBaseBuilder = methodBaseBuilder; }
private void DefineParameter(IMethodBaseBuilder methodBaseBuilder, MutableParameterInfo parameter) { var parameterBuilder = methodBaseBuilder.DefineParameter(parameter.Position + 1, parameter.Attributes, parameter.Name); DefineCustomAttributes(parameterBuilder, parameter); }