public void CreateFromNamespaceWhitelist_IncludesSubNamespaces() { var types = new[] { typeof(Color), typeof(Brush), typeof(DateTime), typeof(ImageFlags) }; var mockRepository = new MockRepository(); var decoratedTypeDiscoveryServiceMock = mockRepository.Stub <ITypeDiscoveryService>(); decoratedTypeDiscoveryServiceMock.Stub(service => service.GetTypes(Arg <Type> .Is.Anything, Arg <bool> .Is.Anything)).Return(types); mockRepository.ReplayAll(); var filteringTypeDiscoveryService = FilteringTypeDiscoveryService.CreateFromNamespaceWhitelist( decoratedTypeDiscoveryServiceMock, typeof(Color).Namespace); var filteredTypes = filteringTypeDiscoveryService.GetTypes(null, false); Assert.That( filteredTypes.Cast <Type>().ToArray(), Is.EqualTo( new[] { typeof(Color), typeof(Brush), typeof(ImageFlags) })); }
public ITypeDiscoveryService GetTypeDiscoveryService(params Assembly[] rootAssemblies) { var baseTypeDiscoveryService = new FixedTypeDiscoveryService(Assembly.GetExecutingAssembly().GetTypes()); return(FilteringTypeDiscoveryService.CreateFromNamespaceWhitelist( baseTypeDiscoveryService, "Remotion.Data.DomainObjects.UnitTests.Persistence.Rdbms.SchemaGenerationTestDomain")); }
private ITypeDiscoveryService GetTypeDiscoveryService(string testDomainNamespace, params Assembly[] rootAssemblies) { var rootAssemblyFinder = new FixedRootAssemblyFinder(rootAssemblies.Select(asm => new RootAssembly(asm, true)).ToArray()); var assemblyLoader = new FilteringAssemblyLoader(ApplicationAssemblyLoaderFilter.Instance); var assemblyFinder = new CachingAssemblyFinderDecorator(new AssemblyFinder(rootAssemblyFinder, assemblyLoader)); ITypeDiscoveryService typeDiscoveryService = new AssemblyFinderTypeDiscoveryService(assemblyFinder); return(FilteringTypeDiscoveryService.CreateFromNamespaceWhitelist(typeDiscoveryService, testDomainNamespace)); }
public void SetUp() { var validationTestDomainNamespace = typeof(AbstractMixinWithoutBase).Namespace; var globalTestDomainNamespace = typeof(BaseType1).Namespace; var typeDiscoveryService = FilteringTypeDiscoveryService.CreateFromNamespaceWhitelist( ContextAwareTypeUtility.GetTypeDiscoveryService(), validationTestDomainNamespace, globalTestDomainNamespace); var types = typeDiscoveryService.GetTypes(null, false); _configurationScope = DeclarativeConfigurationBuilder.BuildConfigurationFromTypes(null, types.Cast <Type>()).EnterScope(); }
public static ITypeDiscoveryService GetTypeDiscoveryService() { var mappingRootNamespace = typeof(TestMappingConfiguration).Namespace; var testMappingNamespace = mappingRootNamespace + ".TestDomain.Integration"; var rootAssemlbies = new[] { new RootAssembly(typeof(TestMappingConfiguration).Assembly, true) }; var rootAssemblyFinder = new FixedRootAssemblyFinder(rootAssemlbies); var assemblyLoader = new FilteringAssemblyLoader(ApplicationAssemblyLoaderFilter.Instance); var assemblyFinder = new CachingAssemblyFinderDecorator(new AssemblyFinder(rootAssemblyFinder, assemblyLoader)); var typeDiscoveryService = (ITypeDiscoveryService) new AssemblyFinderTypeDiscoveryService(assemblyFinder); typeDiscoveryService = FilteringTypeDiscoveryService.CreateFromNamespaceWhitelist(typeDiscoveryService, testMappingNamespace); return(typeDiscoveryService); }
public void CreateFromNamespaceBlacklist_AllowsTypesWithoutNamespace_Exclusion() { var types = new[] { typeof(TypeWithNullNamespace) }; var mockRepository = new MockRepository(); var decoratedTypeDiscoveryServiceMock = mockRepository.Stub <ITypeDiscoveryService>(); decoratedTypeDiscoveryServiceMock.Stub(service => service.GetTypes(Arg <Type> .Is.Anything, Arg <bool> .Is.Anything)).Return(types); mockRepository.ReplayAll(); var filteringTypeDiscoveryService = FilteringTypeDiscoveryService.CreateFromNamespaceBlacklist(decoratedTypeDiscoveryServiceMock, ""); var filteredTypes = filteringTypeDiscoveryService.GetTypes(null, false); Assert.That(filteredTypes, Is.Empty); }
public static ITypeDiscoveryService GetTypeDiscoveryService(params Assembly[] rootAssemblies) { var rootAssemblyFinder = new FixedRootAssemblyFinder(rootAssemblies.Select(asm => new RootAssembly(asm, true)).ToArray()); var assemblyLoader = new FilteringAssemblyLoader(ApplicationAssemblyLoaderFilter.Instance); var assemblyFinder = new CachingAssemblyFinderDecorator(new AssemblyFinder(rootAssemblyFinder, assemblyLoader)); ITypeDiscoveryService typeDiscoveryService = new AssemblyFinderTypeDiscoveryService(assemblyFinder); return(FilteringTypeDiscoveryService.CreateFromNamespaceBlacklist( typeDiscoveryService, "Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.Errors", "Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.Integration", "Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.RelationReflector", "Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.Validation", "Remotion.Data.DomainObjects.UnitTests.Mapping.MappingReflectionIntegrationTests", "Remotion.Data.DomainObjects.UnitTests.Security.TestDomain", "Remotion.Data.DomainObjects.UnitTests.Persistence.Rdbms.SchemaGenerationTestDomain" )); }