public void ShouldUseFactory()
        {
            var partLocator = new PartLocator<NonSharedObject>(true);
            var instance = partLocator.GetPart();

            Assert.IsNotNull(instance);
        }
예제 #2
0
        public void ShouldUseFactory()
        {
            var partLocator = new PartLocator <NonSharedObject>(true);
            var instance    = partLocator.GetPart();

            Assert.IsNotNull(instance);
        }
예제 #3
0
        public void ShouldDiscoverDefault()
        {
            CompositionContext context = CompositionContext.Default
                .WithGenerator(typeof(IEntityManagerSyncInterceptor), () => new SyncInterceptor())
                .WithName("ShouldDiscoverDefault");

            var partLocator1 = new PartLocator<IEntityManagerSyncInterceptor>(false, () => context);
            PartLocator<IEntityManagerSyncInterceptor> partLocator2 = new PartLocator<IEntityManagerSyncInterceptor>()
                .WithDefaultGenerator(() => new DefaultEntityManagerSyncInterceptor());

            IEntityManagerSyncInterceptor obj1 = partLocator1.GetPart();
            Assert.IsTrue(obj1.GetType() == typeof(SyncInterceptor),
                          "Should have found the SyncInterceptor");

            IEntityManagerSyncInterceptor obj2 = partLocator2.GetPart();
            Assert.IsTrue(obj2.GetType() == typeof(DefaultEntityManagerSyncInterceptor),
                          "Should have found the DefaultSyncInterceptor");
        }
예제 #4
0
        public void ShouldDiscoverDefaultSyncInterceptor()
        {
            CompositionContext context = CompositionContext.Default
                                         .WithGenerator(typeof(IEntityManagerSyncInterceptor), () => new SyncInterceptor())
                                         .WithName("ShouldDiscoverDefault");

            var partLocator1 = new PartLocator <IEntityManagerSyncInterceptor>(false, () => context);
            PartLocator <IEntityManagerSyncInterceptor> partLocator2 = new PartLocator <IEntityManagerSyncInterceptor>()
                                                                       .WithDefaultGenerator(() => new DefaultEntityManagerSyncInterceptor());

            IEntityManagerSyncInterceptor obj1 = partLocator1.GetPart();

            Assert.IsTrue(obj1.GetType() == typeof(SyncInterceptor),
                          "Should have found the SyncInterceptor");

            IEntityManagerSyncInterceptor obj2 = partLocator2.GetPart();

            Assert.IsTrue(obj2.GetType() == typeof(DefaultEntityManagerSyncInterceptor),
                          "Should have found the DefaultSyncInterceptor");
        }