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 ShouldDiscoverInjectedAuthenticationService() { var injectedService = new AuthenticationService(); CompositionContext ctx = CompositionContext.Default .WithGenerator(typeof(IAuthenticationService), () => injectedService) .WithName("ShouldDiscoverInjectedAuthenticationService"); IAuthenticationService auth1 = new PartLocator<IAuthenticationService>(false, () => ctx).GetPart(); IAuthenticationService auth2 = new PartLocator<IAuthenticationService>().GetPart(); Assert.IsNotNull(auth1, "AuthenticationServer should not be null"); Assert.IsNull(auth2, "AuthenticationService should be null"); Assert.IsTrue(ReferenceEquals(auth1, injectedService), "Should have found service in CompositionContext"); }
public void ShouldDiscoverInjectedAuthenticationService() { var injectedService = new AuthenticationService(); CompositionContext ctx = CompositionContext.Default .WithGenerator(typeof(IAuthenticationService), () => injectedService) .WithName("ShouldDiscoverInjectedAuthenticationService"); IAuthenticationService auth1 = new PartLocator <IAuthenticationService>(false, () => ctx).GetPart(); IAuthenticationService auth2 = new PartLocator <IAuthenticationService>().GetPart(); Assert.IsNotNull(auth1, "AuthenticationServer should not be null"); Assert.IsNull(auth2, "AuthenticationService should be null"); Assert.IsTrue(ReferenceEquals(auth1, injectedService), "Should have found service in CompositionContext"); }
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"); }