private void CheckGetEmittable <T> (Func <IEmittableOperandProvider, T, T> getEmittableOperandFunc, T operand, T emittableOperand, Type checkedType)
        {
            _innerMock.Expect(mock => getEmittableOperandFunc(mock, operand)).Return(emittableOperand);
            _typeAnalyzerMock.Expect(mock => mock.IsStrongNamed(checkedType)).Return(true);

            var result = getEmittableOperandFunc(_decorator, operand);

            _innerMock.VerifyAllExpectations();
            _typeAnalyzerMock.VerifyAllExpectations();
            Assert.That(result, Is.SameAs(emittableOperand));

            _innerMock.BackToRecord();
            _typeAnalyzerMock.BackToRecord();
            _innerMock.Expect(mock => getEmittableOperandFunc(mock, operand)).Return(emittableOperand);
            _typeAnalyzerMock.Expect(mock => mock.IsStrongNamed(checkedType)).Return(false);
            _innerMock.Replay();
            _typeAnalyzerMock.Replay();

            var message = "Strong-naming is enabled but a participant used the type '" + checkedType.FullName + "' which comes from the unsigned assembly '"
                          + checkedType.Assembly.GetName().Name + "'.";

            Assert.That(() => getEmittableOperandFunc(_decorator, operand), Throws.InvalidOperationException.With.Message.EqualTo(message));
            _innerMock.VerifyAllExpectations();
            _typeAnalyzerMock.VerifyAllExpectations();
        }
        public void SetReturnType()
        {
            var returnType          = ReflectionObjectMother.GetSomeType();
            var emittableReturnType = ReflectionObjectMother.GetSomeOtherType();

            _operandProviderMock.Expect(mock => mock.GetEmittableType(returnType)).Return(emittableReturnType);
            _innerMock.Expect(mock => mock.SetReturnType(emittableReturnType));

            _decorator.SetReturnType(returnType);

            _operandProviderMock.VerifyAllExpectations();
            _innerMock.VerifyAllExpectations();
        }
Exemplo n.º 3
0
        public void SetBaseTypeConstraint()
        {
            var baseTypeConstraint          = ReflectionObjectMother.GetSomeType();
            var emittableBaseTypeConstraint = ReflectionObjectMother.GetSomeOtherType();

            _operandProvider.Expect(mock => mock.GetEmittableType(baseTypeConstraint)).Return(emittableBaseTypeConstraint);
            _innerMock.Expect(mock => mock.SetBaseTypeConstraint(emittableBaseTypeConstraint));

            _decorator.SetBaseTypeConstraint(baseTypeConstraint);

            _operandProvider.VerifyAllExpectations();
            _innerMock.VerifyAllExpectations();
        }