public void CreateForeignKeyConstraintDefinitionsFactory()
        {
            IRdbmsStorageObjectFactory testableSqlProviderFactory = new TestableSqlStorageObjectFactory(
                _rdbmsPersistenceModelProviderStub,
                null,
                null,
                _storageNameProviderStub,
                _infrastructureStoragePropertyDefinitionProviderStub,
                null,
                null,
                null,
                null,
                null,
                null);

            var result = testableSqlProviderFactory.CreateForeignKeyConstraintDefinitionsFactory(_rdbmsProviderDefinition);

            Assert.That(result, Is.TypeOf(typeof(ForeignKeyConstraintDefinitionFactory)));
            var resultAsForeignKeyConstraintDefinitionFactory = (ForeignKeyConstraintDefinitionFactory)result;

            Assert.That(resultAsForeignKeyConstraintDefinitionFactory.StorageNameProvider, Is.SameAs(_storageNameProviderStub));
            Assert.That(
                resultAsForeignKeyConstraintDefinitionFactory.InfrastructureStoragePropertyDefinitionProvider,
                Is.SameAs(_infrastructureStoragePropertyDefinitionProviderStub));
            Assert.That(resultAsForeignKeyConstraintDefinitionFactory.PersistenceModelProvider, Is.SameAs(_rdbmsPersistenceModelProviderStub));
        }
        public void CreateStorageProviderCommandFactory()
        {
            IRdbmsStorageObjectFactory testableSqlProviderFactory = new TestableSqlStorageObjectFactory(
                _rdbmsPersistenceModelProviderStub,
                null,
                _dbCommandBuilderFactoryStub,
                null,
                null,
                _dataStoragePropertyDefinitionFactoryStub,
                null,
                null,
                null,
                null,
                null);

            var result = testableSqlProviderFactory.CreateStorageProviderCommandFactory(_rdbmsProviderDefinition);

            Assert.That(result, Is.TypeOf(typeof(RdbmsProviderCommandFactory)));
            var resultAsRdbmsProviderCommandFactory = (RdbmsProviderCommandFactory)result;

            Assert.That(resultAsRdbmsProviderCommandFactory.StorageProviderDefinition, Is.SameAs(_rdbmsProviderDefinition));
            Assert.That(resultAsRdbmsProviderCommandFactory.DbCommandBuilderFactory, Is.SameAs(_dbCommandBuilderFactoryStub));
            Assert.That(resultAsRdbmsProviderCommandFactory.RdbmsPersistenceModelProvider, Is.SameAs(_rdbmsPersistenceModelProviderStub));
            Assert.That(resultAsRdbmsProviderCommandFactory.DataStoragePropertyDefinitionFactory, Is.SameAs(_dataStoragePropertyDefinitionFactoryStub));
            var objectReader = resultAsRdbmsProviderCommandFactory.ObjectReaderFactory.CreateDataContainerReader();

            Assert.That(objectReader, Is.TypeOf(typeof(DataContainerReader)));
            var expectedDataContainerValidator = SafeServiceLocator.Current.GetInstance <IDataContainerValidator>();

            Assert.That(((DataContainerReader)objectReader).DataContainerValidator, Is.SameAs(expectedDataContainerValidator));
        }
        public void CreateDataStoragePropertyDefinitionFactory()
        {
            IRdbmsStorageObjectFactory testableSqlProviderFactory = new TestableSqlStorageObjectFactory(
                null,
                null,
                null,
                null,
                null,
                null,
                _valueStoragePropertyDefinitonFactoryStub,
                _relationStoragePropertyDefiniitonFactoryStub,
                null,
                null,
                null);

            var result = testableSqlProviderFactory.CreateDataStoragePropertyDefinitionFactory(_rdbmsProviderDefinition);

            Assert.That(result, Is.TypeOf(typeof(DataStoragePropertyDefinitionFactory)));
            var resultAsDataStoragePropertyDefinitionFactory = (DataStoragePropertyDefinitionFactory)result;

            Assert.That(
                resultAsDataStoragePropertyDefinitionFactory.RelationStoragePropertyDefinitionFactory,
                Is.SameAs(_relationStoragePropertyDefiniitonFactoryStub));
            Assert.That(
                resultAsDataStoragePropertyDefinitionFactory.ValueStoragePropertyDefinitionFactory, Is.SameAs(_valueStoragePropertyDefinitonFactoryStub));
        }
        public void CreateEntityDefinitionFactory()
        {
            IRdbmsStorageObjectFactory testableSqlProviderFactory = new TestableSqlStorageObjectFactory(
                null,
                null,
                null,
                _storageNameProviderStub,
                _infrastructureStoragePropertyDefinitionProviderStub,
                null,
                null,
                null,
                null,
                _foreignKeyConstraintDefinitionFactoryStub,
                _storagePropertyDefinitionResolverStub);

            var result = testableSqlProviderFactory.CreateEntityDefinitionFactory(_rdbmsProviderDefinition);

            Assert.That(result, Is.TypeOf(typeof(RdbmsStorageEntityDefinitionFactory)));
            var resultAsRdmsStorageEntityDefinitionFactory = (RdbmsStorageEntityDefinitionFactory)result;

            Assert.That(resultAsRdmsStorageEntityDefinitionFactory.StorageProviderDefinition, Is.SameAs(_rdbmsProviderDefinition));
            Assert.That(
                resultAsRdmsStorageEntityDefinitionFactory.InfrastructureStoragePropertyDefinitionProvider,
                Is.SameAs(_infrastructureStoragePropertyDefinitionProviderStub));
            Assert.That(resultAsRdmsStorageEntityDefinitionFactory.StorageNameProvider, Is.SameAs(_storageNameProviderStub));
            Assert.That(
                resultAsRdmsStorageEntityDefinitionFactory.ForeignKeyConstraintDefinitionFactory, Is.SameAs(_foreignKeyConstraintDefinitionFactoryStub));
            Assert.That(resultAsRdmsStorageEntityDefinitionFactory.StoragePropertyDefinitionResolver, Is.SameAs(_storagePropertyDefinitionResolverStub));
        }
        public void CreateEnumSerializer()
        {
            var testableSqlProviderFactory = new TestableSqlStorageObjectFactory(null, null);

            var enumSerializer = testableSqlProviderFactory.CreateEnumSerializer();

            Assert.That(enumSerializer, Is.InstanceOf <ExtensibleEnumSerializerDecorator>());
        }
        public void CreateStorageProviderSerializer()
        {
            var enumSerializerStub         = MockRepository.GenerateStub <IEnumSerializer>();
            var testableSqlProviderFactory = new TestableSqlStorageObjectFactory(null,
                                                                                 enumSerializerStub);

            var storageProviderSerializer = testableSqlProviderFactory.CreateStorageProviderSerializer(enumSerializerStub);

            Assert.That(storageProviderSerializer, Is.InstanceOf <StorageProviderSerializer>());
            Assert.That(
                ((StorageProviderSerializer)storageProviderSerializer).ClassSerializer,
                Is.InstanceOf <ClassSerializer> ());
        }
        public void CreateValueStoragePropertyDefinitionFactory()
        {
            IRdbmsStorageObjectFactory testableSqlProviderFactory = new TestableSqlStorageObjectFactory(
                null, _storageTypeInformationProviderStub, null, _storageNameProviderStub, null, null, null, null, null, null, null);

            var result = testableSqlProviderFactory.CreateValueStoragePropertyDefinitionFactory(_rdbmsProviderDefinition);

            Assert.That(result, Is.TypeOf(typeof(ValueStoragePropertyDefinitionFactory)));
            var resultAsValueStoragePropertyDefinitionFactory = (ValueStoragePropertyDefinitionFactory)result;

            Assert.That(resultAsValueStoragePropertyDefinitionFactory.StorageTypeInformationProvider, Is.SameAs(_storageTypeInformationProviderStub));
            Assert.That(resultAsValueStoragePropertyDefinitionFactory.StorageNameProvider, Is.SameAs(_storageNameProviderStub));
        }
        public void CreateDomainObjectQueryGenerator()
        {
            IRdbmsStorageObjectFactory testableSqlProviderFactory = new TestableSqlStorageObjectFactory(
                null, _storageTypeInformationProviderStub, null, null, null, null, null, null, _sqlQueryGeneratorStub, null, null);
            var mappingConfiguration = MockRepository.GenerateStub <IMappingConfiguration>();

            var result = testableSqlProviderFactory.CreateDomainObjectQueryGenerator(
                _rdbmsProviderDefinition,
                _methodCallTransformerProviderStub,
                _resultOpertatorHandlerRegistryStub,
                mappingConfiguration);

            Assert.That(result, Is.InstanceOf <DomainObjectQueryGenerator>());
            var resultAsDomainObjectQueryGenerator = (DomainObjectQueryGenerator)result;

            Assert.That(resultAsDomainObjectQueryGenerator.SqlQueryGenerator, Is.SameAs(_sqlQueryGeneratorStub));
            Assert.That(resultAsDomainObjectQueryGenerator.StorageTypeInformationProvider, Is.SameAs(_storageTypeInformationProviderStub));
            Assert.That(resultAsDomainObjectQueryGenerator.MappingConfiguration, Is.SameAs(mappingConfiguration));
        }
        public void CreateSchemaScriptBuilder()
        {
            IRdbmsStorageObjectFactory testableSqlProviderFactory = new TestableSqlStorageObjectFactory(
                _tableBuilderStub, _viewBuilderStub, _constraintBuilderStub, _indexBuilderStub, _synonymBuilderStub);

            var result = testableSqlProviderFactory.CreateSchemaScriptBuilder(_rdbmsProviderDefinition);

            Assert.That(result, Is.TypeOf(typeof(SqlDatabaseSelectionScriptElementBuilder)));
            Assert.That(((SqlDatabaseSelectionScriptElementBuilder)result).InnerScriptBuilder, Is.TypeOf(typeof(CompositeScriptBuilder)));
            Assert.That(
                ((CompositeScriptBuilder)((SqlDatabaseSelectionScriptElementBuilder)result).InnerScriptBuilder).RdbmsProviderDefinition,
                Is.SameAs(_rdbmsProviderDefinition));
            Assert.That(
                ((CompositeScriptBuilder)((SqlDatabaseSelectionScriptElementBuilder)result).InnerScriptBuilder).ScriptBuilders,
                Is.EqualTo(
                    new IScriptBuilder[]
            {
                _tableBuilderStub,
                _constraintBuilderStub,
                _viewBuilderStub,
                _indexBuilderStub,
                _synonymBuilderStub
            }));
        }