public void SetParent()
        {
            var baseType = ReflectionObjectMother.GetSomeSubclassableType();

            var emittableType = ReflectionObjectMother.GetSomeOtherType();

            _operandProvider.Expect(mock => mock.GetEmittableType(baseType)).Return(emittableType);
            _innerMock.Expect(mock => mock.SetParent(emittableType));

            _decorator.SetParent(baseType);

            _operandProvider.VerifyAllExpectations();
            _innerMock.VerifyAllExpectations();
        }
Esempio n. 2
0
        public void DeclareType()
        {
            var fakeTypeBuilder = MockRepository.GenerateStub <ITypeBuilder>();

            _enclosingTypeBuilderMock.Expect(mock => mock.DefineNestedType(_mutableType.Name, _mutableType.Attributes)).Return(fakeTypeBuilder);
            var codeGeneratorStub            = MockRepository.GenerateStub <IReflectionEmitCodeGenerator>();
            var emittableOperandProviderStub = MockRepository.GenerateStub <IEmittableOperandProvider>();

            var result = _generator.Invoke("DefineType", codeGeneratorStub, emittableOperandProviderStub);

            _enclosingTypeBuilderMock.VerifyAllExpectations();
            Assert.That(result, Is.SameAs(fakeTypeBuilder));
        }
Esempio n. 3
0
        public virtual void DeclareType()
        {
            using (_mockRepository.Ordered())
            {
                _codeGeneratorMock
                .Expect(mock => mock.DefineType(_mutableType.FullName, _mutableType.Attributes, _emittableOperandProviderMock))
                .Return(_typeBuilderMock);
                _typeBuilderMock.Expect(mock => mock.RegisterWith(_emittableOperandProviderMock, _mutableType));
                _codeGeneratorMock.Expect(mock => mock.DebugInfoGenerator).Return(_debugInfoGeneratorMock);
            }
            _mockRepository.ReplayAll();

            _generator.DeclareType();

            _mockRepository.VerifyAll();
            var context = (CodeGenerationContext)PrivateInvoke.GetNonPublicField(_generator, "_context");

            Assert.That(context, Is.Not.Null);
            Assert.That(context.MutableType, Is.SameAs(_mutableType));
            Assert.That(context.TypeBuilder, Is.SameAs(_typeBuilderMock));
            Assert.That(context.DebugInfoGenerator, Is.SameAs(_debugInfoGeneratorMock));
            Assert.That(context.EmittableOperandProvider, Is.SameAs(_emittableOperandProviderMock));
        }