コード例 #1
0
        public override void SetUp()
        {
            base.SetUp();

            DomainObjectsConfiguration.SetCurrent(SchemaGenerationConfiguration.Instance.GetDomainObjectsConfiguration());
            MappingConfiguration.SetCurrent(SchemaGenerationConfiguration.Instance.GetMappingConfiguration());
        }
コード例 #2
0
 public override void TestFixtureSetUp()
 {
     base.TestFixtureSetUp();
     DomainObjectsConfiguration.SetCurrent(TableInheritanceConfiguration.Instance.GetDomainObjectsConfiguration());
     MappingConfiguration.SetCurrent(StandardConfiguration.Instance.GetMappingConfiguration());
     ConfigurationWrapper.SetCurrent(null);
 }
コード例 #3
0
        protected TestMappingConfiguration()
        {
            ProviderCollection <StorageProviderDefinition> storageProviderDefinitionCollection = StorageProviderDefinitionObjectMother.CreateTestDomainStorageProviders();

            _storageConfiguration = new StorageConfiguration(
                storageProviderDefinitionCollection, storageProviderDefinitionCollection[MappingReflectionTestBase.DefaultStorageProviderID]);
            _storageConfiguration.StorageGroups.Add(new StorageGroupElement(new TestDomainAttribute(), MappingReflectionTestBase.c_testDomainProviderID));
            _storageConfiguration.StorageGroups.Add(
                new StorageGroupElement(new StorageProviderStubAttribute(), MappingReflectionTestBase.c_unitTestStorageProviderStubID));
            _storageConfiguration.StorageGroups.Add(
                new StorageGroupElement(new TableInheritanceTestDomainAttribute(), TableInheritanceMappingTest.TableInheritanceTestDomainProviderID));

            _mappingLoaderConfiguration = new MappingLoaderConfiguration();
            _queryConfiguration         = new QueryConfiguration("QueriesForStandardMapping.xml");
            DomainObjectsConfiguration.SetCurrent(
                new FakeDomainObjectsConfiguration(_mappingLoaderConfiguration, _storageConfiguration, _queryConfiguration));

            var typeDiscoveryService = GetTypeDiscoveryService();

            _mappingConfiguration = new MappingConfiguration(
                MappingReflectorObjectMother.CreateMappingReflector(typeDiscoveryService),
                new PersistenceModelLoader(new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage)));
            MappingConfiguration.SetCurrent(_mappingConfiguration);

            _domainObjectIDs = new DomainObjectIDs();
        }
コード例 #4
0
        public static void Initialize()
        {
            ProviderCollection <StorageProviderDefinition> providers = new ProviderCollection <StorageProviderDefinition>();

            providers.Add(new RdbmsProviderDefinition("PerformanceTestDomain", new SqlStorageObjectFactory(), ConnectionString));
            StorageConfiguration storageConfiguration = new StorageConfiguration(providers, providers["PerformanceTestDomain"]);

            DomainObjectsConfiguration.SetCurrent(new FakeDomainObjectsConfiguration(storage: storageConfiguration));


            var rootAssemblyFinder = new FixedRootAssemblyFinder(new RootAssembly(typeof(StandardConfiguration).Assembly, true));
            var assemblyLoader     = new FilteringAssemblyLoader(ApplicationAssemblyLoaderFilter.Instance);
            var assemblyFinder     = new CachingAssemblyFinderDecorator(new AssemblyFinder(rootAssemblyFinder, assemblyLoader));
            ITypeDiscoveryService typeDiscoveryService = new AssemblyFinderTypeDiscoveryService(assemblyFinder);
            MappingConfiguration  mappingConfiguration = new MappingConfiguration(
                new MappingReflector(
                    typeDiscoveryService,
                    new ClassIDProvider(),
                    new ReflectionBasedMemberInformationNameResolver(),
                    new PropertyMetadataReflector(),
                    new DomainModelConstraintProvider(),
                    MappingReflector.CreateDomainObjectCreator()),
                new PersistenceModelLoader(new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage)));

            MappingConfiguration.SetCurrent(mappingConfiguration);
        }
コード例 #5
0
 public virtual void TestFixtureSetUp()
 {
     DomainObjectsConfiguration.SetCurrent(TestMappingConfiguration.Instance.GetDomainObjectsConfiguration());
     MappingConfiguration.SetCurrent(TestMappingConfiguration.Instance.GetMappingConfiguration());
     ConfigurationWrapper.SetCurrent(null);
     FakeMappingConfiguration.Reset();
 }
コード例 #6
0
        public void SetUp()
        {
            try
            {
                var providers = new ProviderCollection <StorageProviderDefinition>();
                providers.Add(new RdbmsProviderDefinition("TheStorageProvider", new SqlStorageObjectFactory(), TestDomainConnectionString));
                var storageConfiguration = new StorageConfiguration(providers, providers["TheStorageProvider"]);

                DomainObjectsConfiguration.SetCurrent(new FakeDomainObjectsConfiguration(storage: storageConfiguration));

                SqlConnection.ClearAllPools();

                var scriptGenerator = new ScriptGenerator(
                    pd => pd.Factory.CreateSchemaScriptBuilder(pd),
                    new RdbmsStorageEntityDefinitionProvider(),
                    new ScriptToStringConverter());
                var scripts = scriptGenerator.GetScripts(MappingConfiguration.Current.GetTypeDefinitions()).Single();

                var masterAgent = new DatabaseAgent(MasterConnectionString);
                masterAgent.ExecuteBatchFile("Database\\CreateDB.sql", false, DatabaseConfiguration.GetReplacementDictionary());

                var databaseAgent = new DatabaseAgent(TestDomainConnectionString);
                databaseAgent.ExecuteBatchString(scripts.SetUpScript, true);
            }
            catch (Exception e)
            {
                Console.WriteLine("SetUpFixture failed: " + e);
                Console.WriteLine();
                throw;
            }
        }
コード例 #7
0
        protected virtual void InitializeConfiguration(string assemblyDirectory)
        {
            ApplicationAssemblyLoaderFilter filter = ApplicationAssemblyLoaderFilter.Instance;

            // TODO: Duplicates logic from AssemblyFinder? The DLL searching part below can probably be removed.
            List <Assembly> assemblies = new List <Assembly>();
            DirectoryInfo   dir        = new DirectoryInfo(assemblyDirectory);

            foreach (FileInfo file in dir.GetFiles("*.dll"))
            {
                Assembly asm = Assembly.LoadFile(file.FullName);
                if (filter.ShouldConsiderAssembly(asm.GetName()) && filter.ShouldIncludeAssembly(asm))
                {
                    assemblies.Add(asm);
                }
            }
            DomainObjectsConfiguration.SetCurrent(
                new FakeDomainObjectsConfiguration(DomainObjectsConfiguration.Current.MappingLoader, GetPersistenceConfiguration(), new QueryConfiguration()));

            var rootAssemblyFinder = new FixedRootAssemblyFinder(assemblies.Select(a => new RootAssembly(a, false)).ToArray());

            var assemblyLoader = new FilteringAssemblyLoader(filter);
            ITypeDiscoveryService typeDiscoveryService =
                new AssemblyFinderTypeDiscoveryService(new AssemblyFinder(rootAssemblyFinder, assemblyLoader));

            var mappingReflector       = new MappingReflector(typeDiscoveryService);
            var persistenceModelLoader =
                new PersistenceModelLoader(new StorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage));
            var mappingConfiguration = new MappingConfiguration(mappingReflector, persistenceModelLoader);

            MappingConfiguration.SetCurrent(mappingConfiguration);
        }
コード例 #8
0
        public override void TestFixtureTearDown()
        {
            DomainObjectsConfiguration.SetCurrent(null);
            MappingConfiguration.SetCurrent(null);
            ConfigurationWrapper.SetCurrent(null);

            base.TestFixtureTearDown();
        }
コード例 #9
0
        public override void SetUp()
        {
            base.SetUp();

            DomainObjectsConfiguration.SetCurrent(StandardConfiguration.Instance.GetDomainObjectsConfiguration());
            MappingConfiguration.SetCurrent(StandardConfiguration.Instance.GetMappingConfiguration());
            ConfigurationWrapper.SetCurrent(null);
        }
コード例 #10
0
 public override void SetUp()
 {
     base.SetUp();
     DomainObjectsConfiguration.SetCurrent(TableInheritanceConfiguration.Instance.GetDomainObjectsConfiguration());
     MappingConfiguration.SetCurrent(TableInheritanceConfiguration.Instance.GetMappingConfiguration());
     ConfigurationWrapper.SetCurrent(null);
     _transactionScope = ClientTransaction.CreateRootTransaction().EnterDiscardingScope();
 }
コード例 #11
0
        public void GetAndSet()
        {
            IDomainObjectsConfiguration configuration =
                new FakeDomainObjectsConfiguration(new MappingLoaderConfiguration(), new StorageConfiguration(), new QueryConfiguration());

            DomainObjectsConfiguration.SetCurrent(configuration);

            Assert.That(DomainObjectsConfiguration.Current, Is.SameAs(configuration));
        }
コード例 #12
0
        protected virtual void InitializeConfiguration()
        {
            DomainObjectsConfiguration.SetCurrent(
                new FakeDomainObjectsConfiguration(
                    DomainObjectsConfiguration.Current.MappingLoader, GetPersistenceConfiguration(), new QueryConfiguration()));

            MappingConfiguration.SetCurrent(
                new MappingConfiguration(
                    DomainObjectsConfiguration.Current.MappingLoader.CreateMappingLoader(),
                    new PersistenceModelLoader(new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage))));
        }
コード例 #13
0
        public virtual void SetUp()
        {
            DomainObjectsConfiguration.SetCurrent(TestMappingConfiguration.Instance.GetDomainObjectsConfiguration());
            MappingConfiguration.SetCurrent(TestMappingConfiguration.Instance.GetMappingConfiguration());
            ConfigurationWrapper.SetCurrent(null);

            ClassIDProviderStub = MockRepository.GenerateStub <IClassIDProvider>();
            DomainModelConstraintProviderStub = MockRepository.GenerateStub <IDomainModelConstraintProvider>();
            DomainObjectCreatorStub           = MockRepository.GenerateStub <IDomainObjectCreator>();
            PropertyMetadataProvider          = new PropertyMetadataReflector();

            MappingObjectFactory = new ReflectionBasedMappingObjectFactory(
                Configuration.NameResolver, ClassIDProviderStub, PropertyMetadataProvider, DomainModelConstraintProviderStub, DomainObjectCreatorStub);
        }
コード例 #14
0
        public void UnknownQueryDefinitionInQueryConfiguration()
        {
            QueryDefinition unknownQueryDefinition = new QueryDefinition("UnknownQuery", TestDomainStorageProviderDefinition, "select 42", QueryType.Scalar);

            DomainObjectsConfiguration.Current.Query.QueryDefinitions.Add(unknownQueryDefinition);

            using (MemoryStream stream = new MemoryStream())
            {
                Serialize(stream, unknownQueryDefinition);
                DomainObjectsConfiguration.SetCurrent(
                    new FakeDomainObjectsConfiguration(
                        DomainObjectsConfiguration.Current.MappingLoader, DomainObjectsConfiguration.Current.Storage, new QueryConfiguration()));

                Deserialize(stream);
            }
        }
コード例 #15
0
        public void SetUp()
        {
            try
            {
                var serviceLocator = DefaultServiceLocator.Create();
                serviceLocator.RegisterSingle <ISecurityProvider> (() => new NullSecurityProvider());
                serviceLocator.RegisterSingle <IPrincipalProvider> (() => new NullPrincipalProvider());
                ServiceLocator.SetLocatorProvider(() => serviceLocator);

                var providers = new ProviderCollection <StorageProviderDefinition>();
                providers.Add(new RdbmsProviderDefinition("SecurityManager", new SecurityManagerSqlStorageObjectFactory(), TestDomainConnectionString));
                var storageConfiguration = new StorageConfiguration(providers, providers["SecurityManager"]);
                storageConfiguration.StorageGroups.Add(new StorageGroupElement(new SecurityManagerStorageGroupAttribute(), "SecurityManager"));

                DomainObjectsConfiguration.SetCurrent(new FakeDomainObjectsConfiguration(storage: storageConfiguration));

                var rootAssemblyFinder = new FixedRootAssemblyFinder(new RootAssembly(typeof(BaseSecurityManagerObject).Assembly, true));
                var assemblyLoader     = new FilteringAssemblyLoader(ApplicationAssemblyLoaderFilter.Instance);
                var assemblyFinder     = new CachingAssemblyFinderDecorator(new AssemblyFinder(rootAssemblyFinder, assemblyLoader));
                ITypeDiscoveryService typeDiscoveryService = new AssemblyFinderTypeDiscoveryService(assemblyFinder);

                MappingConfiguration.SetCurrent(
                    new MappingConfiguration(
                        new MappingReflector(
                            typeDiscoveryService,
                            new ClassIDProvider(),
                            new ReflectionBasedMemberInformationNameResolver(),
                            new PropertyMetadataReflector(),
                            new DomainModelConstraintProvider(),
                            MappingReflector.CreateDomainObjectCreator()),
                        new PersistenceModelLoader(new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage))));

                SqlConnection.ClearAllPools();

                DatabaseAgent masterAgent = new DatabaseAgent(MasterConnectionString);
                masterAgent.ExecuteBatchFile("SecurityManagerCreateDB.sql", false, DatabaseConfiguration.GetReplacementDictionary());
                DatabaseAgent databaseAgent = new DatabaseAgent(TestDomainConnectionString);
                databaseAgent.ExecuteBatchFile("SecurityManagerSetupDB.sql", true);
                databaseAgent.ExecuteBatchFile("SecurityManagerSetupConstraints.sql", true);
                databaseAgent.ExecuteBatchFile("SecurityManagerSetupDBSpecialTables.sql", true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #16
0
        public void SetUp()
        {
            try
            {
                var providers = new ProviderCollection <StorageProviderDefinition>();
                providers.Add(new RdbmsProviderDefinition(StubStorageProvider.StorageProviderID, new StubStorageFactory(), "NonExistingRdbms"));
                var storageConfiguration = new StorageConfiguration(providers, providers[StubStorageProvider.StorageProviderID]);
                DomainObjectsConfiguration.SetCurrent(new FakeDomainObjectsConfiguration(storage: storageConfiguration));

                Dev.Null = MappingConfiguration.Current;
            }
            catch (Exception ex)
            {
                Console.WriteLine("SetUpFixture failed: " + ex);
                Console.WriteLine();
                throw;
            }
        }
コード例 #17
0
        public void SetUp()
        {
            try
            {
                ProviderCollection <StorageProviderDefinition> providers = new ProviderCollection <StorageProviderDefinition>();
                providers.Add(new RdbmsProviderDefinition("Development.Data.DomainObjects", new SqlStorageObjectFactory(), "ConnectionString"));
                StorageConfiguration storageConfiguration = new StorageConfiguration(providers, providers["Development.Data.DomainObjects"]);

                DomainObjectsConfiguration.SetCurrent(
                    new FakeDomainObjectsConfiguration(
                        new MappingLoaderConfiguration(),
                        storageConfiguration,
                        new QueryConfiguration()));

                var rootAssemblyFinder = new FixedRootAssemblyFinder(new RootAssembly(typeof(TestDomainObject).Assembly, true));
                var assemblyLoader     = new FilteringAssemblyLoader(ApplicationAssemblyLoaderFilter.Instance);
                var assemblyFinder     = new CachingAssemblyFinderDecorator(new AssemblyFinder(rootAssemblyFinder, assemblyLoader));
                ITypeDiscoveryService typeDiscoveryService = new AssemblyFinderTypeDiscoveryService(assemblyFinder);

                MappingConfiguration.SetCurrent(
                    new MappingConfiguration(
                        new MappingReflector(
                            typeDiscoveryService,
                            new ClassIDProvider(),
                            new ReflectionBasedMemberInformationNameResolver(),
                            new PropertyMetadataReflector(),
                            new DomainModelConstraintProvider(),
                            new ThrowingDomainObjectCreator()),
                        new PersistenceModelLoader(new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage))));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
コード例 #18
0
 public void SetUp()
 {
     DomainObjectsConfiguration.SetCurrent(null);
 }