public void ShouldUseFactory() { var partLocator = new PartLocator<NonSharedObject>(true); var instance = partLocator.GetPart(); Assert.IsNotNull(instance); }
public void ShouldUseFactory() { var partLocator = new PartLocator <NonSharedObject>(true); var instance = partLocator.GetPart(); Assert.IsNotNull(instance); }
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"); }
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"); }