public void GetStorageProviderDefinition_ClassWithStorageGroupType_StorageGroupNotDefined_DefaultStorageProviderDefinitionDefined() { var finder = new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage); var result = finder.GetStorageProviderDefinition(typeof(StubStorageGroup1Attribute), null); Assert.That(result.Name, Is.EqualTo("DefaultStorageProvider")); }
// types // static members and constants // member fields // construction and disposing //TODO: resolve parameter public QueryConfigurationLoader(string configurationFile, StorageGroupBasedStorageProviderDefinitionFinder storageProviderDefinitionFinder) { try { Initialize( configurationFile, SchemaLoader.Queries, true, PrefixNamespace.QueryConfigurationNamespace); } catch (ConfigurationException e) { throw CreateQueryConfigurationException( e, "Error while reading query configuration: {0} File: '{1}'.", e.Message, Path.GetFullPath(configurationFile)); } catch (XmlSchemaException e) { throw CreateQueryConfigurationException( e, "Error while reading query configuration: {0} File: '{1}'.", e.Message, Path.GetFullPath(configurationFile)); } catch (XmlException e) { throw CreateQueryConfigurationException( e, "Error while reading query configuration: {0} File: '{1}'.", e.Message, Path.GetFullPath(configurationFile)); } _storageProviderDefinitionFinder = storageProviderDefinitionFinder; }
public override void SetUp() { base.SetUp(); var rdbmsPersistenceModelProvider = new RdbmsPersistenceModelProvider(); var storageTypeInformationProvider = new SqlStorageTypeInformationProvider(); var dataContainerValidator = new CompoundDataContainerValidator(Enumerable.Empty <IDataContainerValidator>()); var storageNameProvider = new ReflectionBasedStorageNameProvider(); var infrastructureStoragePropertyDefinitionProvider = new InfrastructureStoragePropertyDefinitionProvider(storageTypeInformationProvider, storageNameProvider); var storageProviderDefinitionFinder = new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage); var dataStoragePropertyDefinitionFactory = new DataStoragePropertyDefinitionFactory( new ValueStoragePropertyDefinitionFactory(storageTypeInformationProvider, storageNameProvider), new RelationStoragePropertyDefinitionFactory( TestDomainStorageProviderDefinition, false, storageNameProvider, storageTypeInformationProvider, storageProviderDefinitionFinder)); _factory = new RdbmsProviderCommandFactory( TestDomainStorageProviderDefinition, new SqlDbCommandBuilderFactory(new SqlDialect()), rdbmsPersistenceModelProvider, new ObjectReaderFactory( rdbmsPersistenceModelProvider, infrastructureStoragePropertyDefinitionProvider, storageTypeInformationProvider, dataContainerValidator), new TableDefinitionFinder(rdbmsPersistenceModelProvider), dataStoragePropertyDefinitionFactory); _objectID1 = DomainObjectIDs.Order1; _objectID2 = DomainObjectIDs.Order3; _objectID3 = DomainObjectIDs.Order4; }
public void GetStorageProviderDefinition_ClassWithoutStorageGroupType_DefaultStorageProviderDefinitionDefined() { var finder = new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage); var result = finder.GetStorageProviderDefinition((Type)null, null); Assert.That(result.Name, Is.EqualTo("DefaultStorageProvider")); }
public void GetStorageProviderDefinition_ClassDefinition() { var finder = new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage); var result = finder.GetStorageProviderDefinition(Configuration.GetTypeDefinition(typeof(Order)), null); Assert.That(result, Is.SameAs(TestDomainStorageProviderDefinition)); }
private QueryDefinitionCollection LoadAllQueryDefinitions() { var storageProviderDefinitionFinder = new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage); if (QueryFiles.Count == 0) { return(new QueryConfigurationLoader(GetDefaultQueryFilePath(), storageProviderDefinitionFinder).GetQueryDefinitions()); } else { QueryDefinitionCollection result = new QueryDefinitionCollection(); for (int i = 0; i < QueryFiles.Count; i++) { QueryConfigurationLoader loader = new QueryConfigurationLoader(QueryFiles[i].RootedFileName, storageProviderDefinitionFinder); QueryDefinitionCollection queryDefinitions = loader.GetQueryDefinitions(); try { result.Merge(queryDefinitions); } catch (DuplicateQueryDefinitionException ex) { string message = string.Format("File '{0}' defines a duplicate for query definition '{1}'.", QueryFiles[i].RootedFileName, ex.QueryDefinition.ID); throw new ConfigurationException(message); } } return(result); } }
private IEnumerable <ClassDefinition> GetTypeDefinitionsAndValidateMapping(MappingReflector mappingReflector) { var storageGroupBasedStorageProviderDefinitionFinder = new StorageGroupBasedStorageProviderDefinitionFinder( StandardConfiguration.Instance.GetPersistenceConfiguration()); var persistenceModelLoader = new PersistenceModelLoader(storageGroupBasedStorageProviderDefinitionFinder); return(new MappingConfiguration(mappingReflector, persistenceModelLoader).GetTypeDefinitions()); }
public void SetUp() { _rdbmsProviderDefinition = new RdbmsProviderDefinition("TestDomain", new SqlStorageObjectFactory(), "ConnectionString"); _sqlProviderFactory = new SqlStorageObjectFactory(); _persistenceExtensionStub = MockRepository.GenerateStub <IPersistenceExtension>(); _storageProviderDefinitionFinder = new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage); _tableBuilderStub = MockRepository.GenerateStub <TableScriptBuilder> ( MockRepository.GenerateStub <ITableScriptElementFactory>(), new SqlCommentScriptElementFactory()); _viewBuilderStub = MockRepository.GenerateStub <ViewScriptBuilder> ( MockRepository.GenerateStub <IViewScriptElementFactory <TableDefinition> >(), MockRepository.GenerateStub <IViewScriptElementFactory <UnionViewDefinition> >(), MockRepository.GenerateStub <IViewScriptElementFactory <FilterViewDefinition> >(), MockRepository.GenerateStub <IViewScriptElementFactory <EmptyViewDefinition> >(), new SqlCommentScriptElementFactory()); _constraintBuilderStub = MockRepository.GenerateStub <ForeignKeyConstraintScriptBuilder> ( MockRepository.GenerateStub <IForeignKeyConstraintScriptElementFactory>(), new SqlCommentScriptElementFactory()); _indexScriptElementFactoryStub = MockRepository.GenerateStub <SqlIndexScriptElementFactory> ( MockRepository.GenerateStub <ISqlIndexDefinitionScriptElementFactory <SqlIndexDefinition> >(), MockRepository.GenerateStub <ISqlIndexDefinitionScriptElementFactory <SqlPrimaryXmlIndexDefinition> >(), MockRepository.GenerateStub <ISqlIndexDefinitionScriptElementFactory <SqlSecondaryXmlIndexDefinition> >()); _indexBuilderStub = MockRepository.GenerateStub <IndexScriptBuilder> (_indexScriptElementFactoryStub, new SqlCommentScriptElementFactory()); _synonymBuilderStub = MockRepository.GenerateStub <SynonymScriptBuilder> ( MockRepository.GenerateStub <ISynonymScriptElementFactory <TableDefinition> >(), MockRepository.GenerateStub <ISynonymScriptElementFactory <UnionViewDefinition> >(), MockRepository.GenerateStub <ISynonymScriptElementFactory <FilterViewDefinition> >(), MockRepository.GenerateStub <ISynonymScriptElementFactory <EmptyViewDefinition> >(), new SqlCommentScriptElementFactory()); _rdbmsPersistenceModelProviderStub = MockRepository.GenerateStub <IRdbmsPersistenceModelProvider>(); _storageTypeInformationProviderStub = MockRepository.GenerateStub <IStorageTypeInformationProvider>(); _dbCommandBuilderFactoryStub = MockRepository.GenerateStub <IDbCommandBuilderFactory>(); MockRepository.GeneratePartialMock <SqlSynonymScriptElementFactory>(); _storageNameProviderStub = MockRepository.GenerateStub <IStorageNameProvider>(); _infrastructureStoragePropertyDefinitionProviderStub = MockRepository.GenerateStub <IInfrastructureStoragePropertyDefinitionProvider>(); _dataStoragePropertyDefinitionFactoryStub = MockRepository.GenerateStub <IDataStoragePropertyDefinitionFactory>(); _valueStoragePropertyDefinitonFactoryStub = MockRepository.GenerateStub <IValueStoragePropertyDefinitionFactory>(); _relationStoragePropertyDefiniitonFactoryStub = MockRepository.GenerateStub <IRelationStoragePropertyDefinitionFactory>(); _methodCallTransformerProviderStub = MockRepository.GenerateStub <IMethodCallTransformerProvider>(); _resultOpertatorHandlerRegistryStub = MockRepository.GeneratePartialMock <ResultOperatorHandlerRegistry>(); _sqlQueryGeneratorStub = MockRepository.GenerateStub <ISqlQueryGenerator>(); _foreignKeyConstraintDefinitionFactoryStub = MockRepository.GenerateStub <IForeignKeyConstraintDefinitionFactory>(); _storagePropertyDefinitionResolverStub = MockRepository.GenerateStub <IStoragePropertyDefinitionResolver>(); }
public void GetStorageProviderDefinition_ClassWithStorageGroupType_StorageGroupDefined() { var providerID = "Remotion.Data.DomainObjects.UnitTests.Persistence.Configuration.StubStorageGroup1Attribute, Remotion.Data.UnitTests"; var storageProviderDefinitionCollection = new ProviderCollection <StorageProviderDefinition> { new UnitTestStorageProviderStubDefinition(providerID) }; var storageConfiguration = new StorageConfiguration( storageProviderDefinitionCollection, DomainObjectsConfiguration.Current.Storage.DefaultStorageProviderDefinition); storageConfiguration.StorageGroups.Add(new StorageGroupElement(new StubStorageGroup1Attribute(), providerID)); var finder = new StorageGroupBasedStorageProviderDefinitionFinder(storageConfiguration); var result = finder.GetStorageProviderDefinition(typeof(StubStorageGroup1Attribute), null); Assert.That(result.Name, Is.EqualTo(providerID)); }
public override void SetUp() { base.SetUp(); _storageProviderDefinitionFinder = new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage); _storageProviderDefinition = (RdbmsProviderDefinition)_storageProviderDefinitionFinder.GetStorageProviderDefinition( storageGroupTypeOrNull: null, errorMessageContext: "SetUp"); var factory = _storageProviderDefinition.Factory; _rdbmsPersistenceModelLoader = (RdbmsPersistenceModelLoader)factory.CreatePersistenceModelLoader(_storageProviderDefinition, _storageProviderDefinitionFinder); _testModel = new RdbmsPersistenceModelLoaderTestHelper(); var infrastructureStoragePropertyDefinitionProvider = ((RdbmsStorageEntityDefinitionFactory)_rdbmsPersistenceModelLoader.EntityDefinitionFactory).InfrastructureStoragePropertyDefinitionProvider; _infrastructureObjectIDStoragePropertyDefinition = infrastructureStoragePropertyDefinitionProvider.GetObjectIDStoragePropertyDefinition(); _infrastructureIDStoragePropertyDefinition = (SimpleStoragePropertyDefinition)_infrastructureObjectIDStoragePropertyDefinition.ValueProperty; _infrastructureClassIDStoragePropertyDefinition = (SimpleStoragePropertyDefinition)_infrastructureObjectIDStoragePropertyDefinition.ClassIDProperty; _infrastructureTimestampStoragePropertyDefinition = (SimpleStoragePropertyDefinition)infrastructureStoragePropertyDefinitionProvider.GetTimestampStoragePropertyDefinition(); _fakeBaseBaseStoragePropertyDefinition = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("BaseBaseProperty"); _fakeBaseStoragePropertyDefinition = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("BaseProperty"); _fakeTableStoragePropertyDefinition1 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("TableProperty1"); _fakeTableStoragePropertyDefinition2 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("TableProperty2"); _fakeDerivedStoragePropertyDefinition1 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("DerivedProperty1"); _fakeDerivedStoragePropertyDefinition2 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("DerivedProperty2"); _fakeDerivedDerivedStoragePropertyDefinition = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("DerivedDerivedProperty"); _testModel.BaseBasePropertyDefinition.SetStorageProperty(_fakeBaseBaseStoragePropertyDefinition); _testModel.BasePropertyDefinition.SetStorageProperty(_fakeBaseStoragePropertyDefinition); _testModel.TablePropertyDefinition1.SetStorageProperty(_fakeTableStoragePropertyDefinition1); _testModel.TablePropertyDefinition2.SetStorageProperty(_fakeTableStoragePropertyDefinition2); _testModel.DerivedPropertyDefinition1.SetStorageProperty(_fakeDerivedStoragePropertyDefinition1); _testModel.DerivedPropertyDefinition2.SetStorageProperty(_fakeDerivedStoragePropertyDefinition2); _testModel.DerivedDerivedPropertyDefinition.SetStorageProperty(_fakeDerivedDerivedStoragePropertyDefinition); }
public override void SetUp() { base.SetUp(); _storageProviderDefinitionFinder = new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage); }
public void GetStorageProviderDefinition_ClassWithStorageGroupType_StorageGroupNotDefined_NoDefaultStorageProviderDefinitionDefined_WithContext() { var finder = new StorageGroupBasedStorageProviderDefinitionFinder(_storageConfigurationWithoutDefaultProvider); finder.GetStorageProviderDefinition(typeof(StubStorageGroup1Attribute), "Test"); }
public void GetStorageProviderDefinition_ClassWithoutStorageGroupType_NoDefaultStorageProviderDefinitionDefined_WithContext() { var finder = new StorageGroupBasedStorageProviderDefinitionFinder(_storageConfigurationWithoutDefaultProvider); finder.GetStorageProviderDefinition((Type)null, "Test"); }