Beispiel #1
0
        public void CanCreateAdviceWithDependency()
        {
            //Arrange
            var config = new Configuration();

            config.Add <MEFTestAdviceWithDependency>(new InlinePointcut(type => type == typeof(TargetWithConstructorDepedency)));

            var catalog   = new AssemblyCatalog(Assembly.GetExecutingAssembly());
            var batch     = new CompositionBatch();
            var container = new ForceFieldContainer(catalog, config);

            container.Compose(batch);

            //Act & Assert
            var target = container.GetExportedValue <ITargetWithConstructorDepedency>();

            Assert.IsNotNull(target);
            target.ConsumeDependency();
        }
Beispiel #2
0
        public void ComposeCreatesProxy()
        {
            //Arrange
            var config = new Configuration();

            config.Add <TestAdvice>(ApplyAdvice.OnEveryMethod);

            var catalog = new AssemblyCatalog(Assembly.GetExecutingAssembly());
            var batch   = new CompositionBatch();
            var target  = new Target();

            batch.AddPart(target);
            var container = new ForceFieldContainer(catalog, config);

            //Act
            container.Compose(batch);

            //Assert
            Assert.IsNotNull(target.Dependency as IDynamicProxy, "The imported object was not a ForceField proxy");
        }