Esempio n. 1
0
        public void InterceptedInstanceCanBeInjected()
        {
            Builder builder = CreateConfiguredBuilder(GetInjectionSettings(), true);

            builder.Policies.Set <ITypeMappingPolicy>(new TypeMappingPolicy(typeof(ClassThatImplementsInterface), string.Empty), typeof(IInterface), string.Empty);

            ClassThatDependsOnIInterface instance = builder.BuildUp <ClassThatDependsOnIInterface>(null, string.Empty, null);

            Assert.IsNotNull(instance);
            Assert.IsNotNull(instance.Interface);
            Assert.IsTrue(RemotingServices.IsTransparentProxy(instance.Interface));
        }
        public void InterceptedInstanceCanBeInjected()
        {
            Builder    builder    = new Builder();
            PolicyList policyList = CreatePolicyList(GetInjectionSettings(), true);

            // NOTE: this key is a NamedTypeBuildKey just because we are using an enhanced version of the
            // default creation policy that knows about these keys
            policyList.Set <IBuildKeyMappingPolicy>(
                new BuildKeyMappingPolicy(typeof(ClassThatImplementsInterface)),
                typeof(IInterface));

            ClassThatDependsOnIInterface instance
                = (ClassThatDependsOnIInterface)builder.BuildUp(null,
                                                                null,
                                                                policyList,
                                                                baseStrategyChain.MakeStrategyChain(),
                                                                typeof(ClassThatDependsOnIInterface),
                                                                null);

            Assert.IsNotNull(instance);
            Assert.IsNotNull(instance.Interface);
            Assert.IsTrue(RemotingServices.IsTransparentProxy(instance.Interface));
        }