Example #1
0
        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);
        }
Example #2
0
        public void DefineParameter()
        {
            var iSequence     = 7;
            var attributes    = (ParameterAttributes)7;
            var parameterName = "parameter";

            var fakeParameterBuilder = MockRepository.GenerateStub <IParameterBuilder>();

            _innerMock.Expect(mock => mock.DefineParameter(iSequence, attributes, parameterName)).Return(fakeParameterBuilder);

            var result = _decorator.DefineParameter(iSequence, attributes, parameterName);

            _innerMock.VerifyAllExpectations();
            Assert.That(result, Is.TypeOf <ParameterBuilderDecorator>());
            // Use field from base class 'BuilderDecoratorBase'.
            Assert.That(PrivateInvoke.GetNonPublicField(result, "_customAttributeTargetBuilder"), Is.SameAs(fakeParameterBuilder));
        }
Example #3
0
        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();
        }