Beispiel #1
0
        public void SetUp()
        {
            _typeCacheMock = new Mock <ITypeCache> (MockBehavior.Strict);

            _constructorDelegateFactoryMock = new Mock <IConstructorDelegateFactory> (MockBehavior.Strict);

            _constructorCallCache = new ConstructorCallCache(_typeCacheMock.Object, _constructorDelegateFactoryMock.Object);
            _constructorCalls     = (ConcurrentDictionary <ConstructionKey, Delegate>)PrivateInvoke.GetNonPublicField(_constructorCallCache, "_constructorCalls");

            _delegateType   = ReflectionObjectMother.GetSomeDelegateType();
            _allowNonPublic = BooleanObjectMother.GetRandomBoolean();
        }
        public void SetUp()
        {
            _typeAssemblerMock = MockRepository.GenerateStrictMock <ITypeAssembler>();
            _constructorDelegateFactoryMock = MockRepository.GenerateStrictMock <IConstructorDelegateFactory>();

            _cache = new ConstructorForAssembledTypeCache(_typeAssemblerMock, _constructorDelegateFactoryMock);

            _constructorCalls = (ConcurrentDictionary <ConstructorForAssembledTypeCacheKey, Delegate>)PrivateInvoke.GetNonPublicField(_cache, "_constructorCalls");

            _assembledType     = ReflectionObjectMother.GetSomeType();
            _delegateType      = ReflectionObjectMother.GetSomeDelegateType();
            _allowNonPublic    = BooleanObjectMother.GetRandomBoolean();
            _generatedCtorCall = new Func <int> (() => 7);
        }
Beispiel #3
0
        public void GetEmittableType_DelegateTypePlaceholder()
        {
            var mutableReturnType   = MutableTypeObjectMother.Create();
            var emittableReturnType = ReflectionObjectMother.GetSomeOtherType();

            _provider.AddMapping(mutableReturnType, emittableReturnType);
            _provider.AddMapping(_mutableType, _emittableType);
            var delegateTypePlaceholder = new DelegateTypePlaceholder(mutableReturnType, new[] { _mutableType });

            var fakeResult = ReflectionObjectMother.GetSomeDelegateType();

            _delegateProviderMock.Setup(mock => mock.GetDelegateType(mutableReturnType, new[] { _mutableType })).Returns(fakeResult).Verifiable();

            var result = _provider.GetEmittableType(delegateTypePlaceholder);

            Assert.That(result, Is.SameAs(fakeResult));
        }