public override void SetUp()
        {
            base.SetUp();

            _indexScriptElementFactoryStub = MockRepository.GenerateStub <IIndexScriptElementFactory>();

            _builder = new IndexScriptBuilder(_indexScriptElementFactoryStub, new SqlCommentScriptElementFactory());

            _indexDefinition1 = MockRepository.GenerateStub <IIndexDefinition>();
            _indexDefinition2 = MockRepository.GenerateStub <IIndexDefinition>();
            _indexDefinition3 = MockRepository.GenerateStub <IIndexDefinition>();

            _tableDefinition1 = TableDefinitionObjectMother.CreateWithIndexes(
                SchemaGenerationFirstStorageProviderDefinition,
                new[] { _indexDefinition1 });
            _tableDefinition2 = TableDefinitionObjectMother.CreateWithIndexes(
                SchemaGenerationFirstStorageProviderDefinition,
                new[] { _indexDefinition2, _indexDefinition3 });
            _unionViewDefinition1 = UnionViewDefinitionObjectMother.CreateWithIndexes(
                SchemaGenerationFirstStorageProviderDefinition,
                new[] { _indexDefinition1 });
            _unionViewDefinition2 = UnionViewDefinitionObjectMother.CreateWithIndexes(
                SchemaGenerationFirstStorageProviderDefinition,
                new[] { _indexDefinition2, _indexDefinition3 });
            _filterViewDefinition1 = FilterViewDefinitionObjectMother.CreateWithIndexes(
                SchemaGenerationFirstStorageProviderDefinition,
                new[] { _indexDefinition1 });
            _filterViewDefinition2 = FilterViewDefinitionObjectMother.CreateWithIndexes(
                SchemaGenerationFirstStorageProviderDefinition,
                new[] { _indexDefinition2, _indexDefinition3 });

            _fakeElement1 = MockRepository.GenerateStub <IScriptElement>();
            _fakeElement2 = MockRepository.GenerateStub <IScriptElement>();
            _fakeElement3 = MockRepository.GenerateStub <IScriptElement>();
        }
        protected virtual IStorageProviderCommand <IEnumerable <DataContainer>, IRdbmsProviderCommandExecutionContext> CreateForIndirectRelationLookup(
            UnionViewDefinition unionViewDefinition,
            RelationEndPointDefinition foreignKeyEndPoint,
            ObjectID foreignKeyValue,
            SortExpressionDefinition sortExpression)
        {
            var selectedColumns  = unionViewDefinition.ObjectIDProperty.GetColumns();
            var dbCommandBuilder = _dbCommandBuilderFactory.CreateForSelect(
                unionViewDefinition,
                selectedColumns,
                GetComparedColumns(foreignKeyEndPoint, foreignKeyValue),
                GetOrderedColumns(sortExpression));

            var objectIDReader = _objectReaderFactory.CreateObjectIDReader(unionViewDefinition, selectedColumns);

            var objectIDLoadCommand = new MultiObjectIDLoadCommand(new[] { dbCommandBuilder }, objectIDReader);
            var indirectDataContainerLoadCommand = new IndirectDataContainerLoadCommand(objectIDLoadCommand, _storageProviderCommandFactory);

            return(DelegateBasedCommand.Create(
                       indirectDataContainerLoadCommand,
                       lookupResults => lookupResults.Select(
                           result =>
            {
                Assertion.IsNotNull(
                    result.LocatedObject,
                    "Because ID lookup and DataContainer lookup are executed within the same database transaction, the DataContainer can never be null.");
                return result.LocatedObject;
            })));
        }
        public override void SetUp()
        {
            base.SetUp();

            _rdbmsPersistenceModelProvider = new RdbmsPersistenceModelProvider();

            _dbCommandBuilderFactoryStrictMock = MockRepository.GenerateStrictMock <IDbCommandBuilderFactory>();
            _objectReaderFactoryStrictMock     = MockRepository.GenerateStrictMock <IObjectReaderFactory>();
            _dbCommandBuilderStub              = MockRepository.GenerateStub <IDbCommandBuilder> ();
            _dataContainerReaderStub           = MockRepository.GenerateStub <IObjectReader <DataContainer> > ();
            _objectIDReaderStub                = MockRepository.GenerateStub <IObjectReader <ObjectID> > ();
            _fakeStorageProviderCommandFactory = MockRepository.GenerateStub <IStorageProviderCommandFactory <IRdbmsProviderCommandExecutionContext> >();

            _factory = new RelationLookupCommandFactory(
                _fakeStorageProviderCommandFactory,
                _dbCommandBuilderFactoryStrictMock,
                _rdbmsPersistenceModelProvider,
                _objectReaderFactoryStrictMock);

            _tableDefinition     = TableDefinitionObjectMother.Create(TestDomainStorageProviderDefinition, new EntityNameDefinition(null, "Table1"));
            _unionViewDefinition = UnionViewDefinitionObjectMother.Create(
                TestDomainStorageProviderDefinition,
                new EntityNameDefinition(null, "ViewName"),
                _tableDefinition);

            _foreignKeyValue = CreateObjectID(_tableDefinition);
            _foreignKeyStoragePropertyDefinitionStrictMock = MockRepository.GenerateStrictMock <IRdbmsStoragePropertyDefinition>();

            _fakeComparedColumns = new[] { new ColumnValue(ColumnDefinitionObjectMother.IDColumn, _foreignKeyValue.Value) };
        }
Exemplo n.º 4
0
        public IScriptElement GetDropElement(UnionViewDefinition unionViewDefinition, EntityNameDefinition synonymName)
        {
            ArgumentUtility.CheckNotNull("unionViewDefinition", unionViewDefinition);
            ArgumentUtility.CheckNotNull("synonymName", synonymName);

            return(GetSynonymDropScriptStatement(synonymName));
        }
        public void CalculateFullColumnList_OneColumnNotFound()
        {
            var unionViewDefinition = new UnionViewDefinition(
                _storageProviderDefinition,
                new EntityNameDefinition(null, "Test"),
                new[] { _tableDefinition1, _tableDefinition2 },
                _objectIDProperty,
                _timestampProperty,
                new[] { _property1, _property2 },
                new IIndexDefinition[0],
                new EntityNameDefinition[0]);

            var availableColumns = new[]
            {
                ColumnDefinitionObjectMother.IDColumn,
                ColumnDefinitionObjectMother.ClassIDColumn,
                ColumnDefinitionObjectMother.TimestampColumn,
                _property1.ColumnDefinition
            };

            var result = unionViewDefinition.CalculateFullColumnList(availableColumns).ToArray();

            Assert.That(result.Length, Is.EqualTo(5));
            Assert.That(result[0], Is.SameAs(ColumnDefinitionObjectMother.IDColumn));
            Assert.That(result[1], Is.SameAs(ColumnDefinitionObjectMother.ClassIDColumn));
            Assert.That(result[2], Is.SameAs(ColumnDefinitionObjectMother.TimestampColumn));
            Assert.That(result[3], Is.SameAs(_property1.ColumnDefinition));
            Assert.That(result[4], Is.Null);
        }
        public override void SetUp()
        {
            base.SetUp();

            _tableViewElementFactoryStub  = MockRepository.GenerateStub <IViewScriptElementFactory <TableDefinition> >();
            _unionViewElementFactoryStub  = MockRepository.GenerateStub <IViewScriptElementFactory <UnionViewDefinition> >();
            _filterViewElementFactoryStub = MockRepository.GenerateStub <IViewScriptElementFactory <FilterViewDefinition> >();
            _emptyViewElementFactoryStub  = MockRepository.GenerateStub <IViewScriptElementFactory <EmptyViewDefinition> >();

            _builder = new ViewScriptBuilder(
                _tableViewElementFactoryStub,
                _unionViewElementFactoryStub,
                _filterViewElementFactoryStub,
                _emptyViewElementFactoryStub,
                new SqlCommentScriptElementFactory());

            _tableDefinition1      = TableDefinitionObjectMother.Create(SchemaGenerationFirstStorageProviderDefinition);
            _tableDefinition2      = TableDefinitionObjectMother.Create(SchemaGenerationFirstStorageProviderDefinition);
            _unionViewDefinition1  = UnionViewDefinitionObjectMother.Create(SchemaGenerationFirstStorageProviderDefinition);
            _unionViewDefinition2  = UnionViewDefinitionObjectMother.Create(SchemaGenerationFirstStorageProviderDefinition);
            _filterViewDefinition1 = FilterViewDefinitionObjectMother.Create(SchemaGenerationFirstStorageProviderDefinition);
            _filterViewDefinition2 = FilterViewDefinitionObjectMother.Create(SchemaGenerationFirstStorageProviderDefinition);
            _emptyViewDefinition1  = EmptyViewDefinitionObjectMother.Create(SchemaGenerationFirstStorageProviderDefinition);
            _emptyViewDefinition2  = EmptyViewDefinitionObjectMother.Create(SchemaGenerationFirstStorageProviderDefinition);

            _fakeElement1 = MockRepository.GenerateStub <IScriptElement>();
            _fakeElement2 = MockRepository.GenerateStub <IScriptElement>();
            _fakeElement3 = MockRepository.GenerateStub <IScriptElement>();
        }
 private void AddUnionViewDefinition(UnionViewDefinition unionViewDefinition)
 {
     foreach (var synonym in unionViewDefinition.Synonyms)
     {
         AddElements(
             _unionViewElementFactory.GetCreateElement(unionViewDefinition, synonym),
             _unionViewElementFactory.GetDropElement(unionViewDefinition, synonym));
     }
 }
        public void SetUp()
        {
            _validationRule          = new ClassAboveTableIsAbstractValidationRule();
            _abstractClassDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(DerivedValidationDomainObjectClass), isAbstract: true);
            _concreteClassDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(DerivedValidationDomainObjectClass), isAbstract: false);
            var storageProviderDefinition = new UnitTestStorageProviderStubDefinition("DefaultStorageProvider");

            _tableDefinition     = TableDefinitionObjectMother.Create(storageProviderDefinition, new EntityNameDefinition(null, "TableName"));
            _unionViewDefinition = UnionViewDefinitionObjectMother.Create(storageProviderDefinition);
            _emptyViewDefinition = EmptyViewDefinitionObjectMother.Create(storageProviderDefinition);
        }
        public void Initialization_ViewNameNull()
        {
            var unionViewDefinition = new UnionViewDefinition(
                _storageProviderDefinition,
                null,
                new[] { _tableDefinition1, _tableDefinition2 },
                _objectIDProperty,
                _timestampProperty,
                new SimpleStoragePropertyDefinition[0],
                new IIndexDefinition[0],
                new EntityNameDefinition[0]);

            Assert.That(unionViewDefinition.ViewName, Is.Null);
        }
Exemplo n.º 10
0
        public override void SetUp()
        {
            base.SetUp();

            _tableViewElementFactoryStub  = MockRepository.GenerateStub <ISynonymScriptElementFactory <TableDefinition> >();
            _unionViewElementFactoryStub  = MockRepository.GenerateStub <ISynonymScriptElementFactory <UnionViewDefinition> >();
            _filterViewElementFactoryStub = MockRepository.GenerateStub <ISynonymScriptElementFactory <FilterViewDefinition> >();
            _emptyViewElementFactoryStub  = MockRepository.GenerateStub <ISynonymScriptElementFactory <EmptyViewDefinition> >();

            _builder = new SynonymScriptBuilder(
                _tableViewElementFactoryStub,
                _unionViewElementFactoryStub,
                _filterViewElementFactoryStub,
                _emptyViewElementFactoryStub,
                new SqlCommentScriptElementFactory());

            _synonym1 = new EntityNameDefinition(null, "Synonym1");
            _synonym2 = new EntityNameDefinition(null, "Synonym2");
            _synonym3 = new EntityNameDefinition(null, "Synonym3");

            _tableDefinition1 = TableDefinitionObjectMother.CreateWithSynonyms(
                SchemaGenerationFirstStorageProviderDefinition,
                new[] { _synonym1 });
            _tableDefinition2 = TableDefinitionObjectMother.CreateWithSynonyms(
                SchemaGenerationFirstStorageProviderDefinition,
                new[] { _synonym2, _synonym3 });
            _unionViewDefinition1 = UnionViewDefinitionObjectMother.CreateWithSynonyms(
                SchemaGenerationFirstStorageProviderDefinition,
                new[] { _synonym1 });
            _unionViewDefinition2 = UnionViewDefinitionObjectMother.CreateWithSynonyms(
                SchemaGenerationFirstStorageProviderDefinition,
                new[] { _synonym2, _synonym3 });
            _filterViewDefinition1 = FilterViewDefinitionObjectMother.CreateWithSynonyms(
                SchemaGenerationFirstStorageProviderDefinition,
                new[] { _synonym1 });
            _filterViewDefinition2 = FilterViewDefinitionObjectMother.CreateWithSynonyms(
                SchemaGenerationFirstStorageProviderDefinition,
                new[] { _synonym2, _synonym3 });
            _emptyViewDefinition1 = EmptyViewDefinitionObjectMother.CreateWithSynonyms(
                SchemaGenerationFirstStorageProviderDefinition,
                new[] { _synonym1 });
            _emptyViewDefinition2 = EmptyViewDefinitionObjectMother.CreateWithSynonyms(
                SchemaGenerationFirstStorageProviderDefinition,
                new[] { _synonym2, _synonym3 });

            _fakeElement1 = MockRepository.GenerateStub <IScriptElement>();
            _fakeElement2 = MockRepository.GenerateStub <IScriptElement>();
            _fakeElement3 = MockRepository.GenerateStub <IScriptElement>();
        }
        public override void SetUp()
        {
            base.SetUp();

            _tableDefinition      = TableDefinitionObjectMother.Create(TestDomainStorageProviderDefinition);
            _filterViewDefinition = FilterViewDefinitionObjectMother.Create(
                TestDomainStorageProviderDefinition, new EntityNameDefinition(null, "FilterView"), _tableDefinition);
            _unionViewDefinition = UnionViewDefinitionObjectMother.Create(
                TestDomainStorageProviderDefinition, new EntityNameDefinition(null, "UnionView"), new[] { _tableDefinition });
            _emptyViewDefinition = EmptyViewDefinitionObjectMother.Create(TestDomainStorageProviderDefinition);

            _mockRepository      = new MockRepository();
            _voidReceiverMock    = _mockRepository.StrictMock <IVisitorCallReceiver> ();
            _nonVoidReceiverMock = _mockRepository.StrictMock <IVisitorCallReceiver <string> > ();
        }
        public void GetAllTables_IndirectTables()
        {
            var tableDefinition3    = TableDefinitionObjectMother.Create(_storageProviderDefinition);
            var baseUnionDefinition = new UnionViewDefinition(
                _storageProviderDefinition,
                new EntityNameDefinition(null, "UnionView"),
                new IRdbmsStorageEntityDefinition[] { _unionViewDefinition, tableDefinition3 },
                _objectIDProperty,
                _timestampProperty,
                new SimpleStoragePropertyDefinition[0],
                new IIndexDefinition[0],
                new EntityNameDefinition[0]);

            var result = baseUnionDefinition.GetAllTables().ToArray();

            Assert.That(result, Is.EqualTo(new[] { _tableDefinition1, _tableDefinition2, tableDefinition3 }));
        }
        public void SetUp()
        {
            _validationRule = new TableNamesAreDistinctWithinConcreteTableInheritanceHierarchyValidationRule();

            _baseOfBaseClass   = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(BaseOfBaseValidationDomainObjectClass));
            _derivedBaseClass1 = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(BaseValidationDomainObjectClass), baseClass: _baseOfBaseClass);
            _derivedClass      = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(DerivedValidationDomainObjectClass), baseClass: _derivedBaseClass1);

            _baseOfBaseClass.SetDerivedClasses(new[] { _derivedBaseClass1 });
            _derivedBaseClass1.SetDerivedClasses(new[] { _derivedClass });
            _derivedClass.SetDerivedClasses(new ClassDefinition[0]);

            var storageProviderDefinition = new UnitTestStorageProviderStubDefinition("DefaultStorageProvider");

            _tableDefinition1    = TableDefinitionObjectMother.Create(storageProviderDefinition, new EntityNameDefinition(null, "TableName1"));
            _tableDefinition2    = TableDefinitionObjectMother.Create(storageProviderDefinition, new EntityNameDefinition(null, "TableName2"));
            _unionViewDefinition = UnionViewDefinitionObjectMother.Create(storageProviderDefinition);
        }
        public IDbCommandBuilder CreateForSelect(
            UnionViewDefinition view,
            IEnumerable <ColumnDefinition> selectedColumns,
            IEnumerable <ColumnValue> comparedColumnValues,
            IEnumerable <OrderedColumn> orderedColumns)
        {
            ArgumentUtility.CheckNotNull("view", view);
            ArgumentUtility.CheckNotNull("selectedColumns", selectedColumns);
            ArgumentUtility.CheckNotNull("comparedColumnValues", comparedColumnValues);
            ArgumentUtility.CheckNotNull("orderedColumns", orderedColumns);

            return(new UnionSelectDbCommandBuilder(
                       view,
                       new SelectedColumnsSpecification(selectedColumns),
                       new ComparedColumnsSpecification(comparedColumnValues),
                       new OrderedColumnsSpecification(orderedColumns),
                       _sqlDialect));
        }
Exemplo n.º 15
0
        public UnionSelectDbCommandBuilder(
            UnionViewDefinition unionViewDefinition,
            ISelectedColumnsSpecification selectedColumns,
            IComparedColumnsSpecification comparedColumns,
            IOrderedColumnsSpecification orderedColumns,
            ISqlDialect sqlDialect)
            : base(sqlDialect)
        {
            ArgumentUtility.CheckNotNull("unionViewDefinition", unionViewDefinition);
            ArgumentUtility.CheckNotNull("selectedColumns", selectedColumns);
            ArgumentUtility.CheckNotNull("comparedColumns", comparedColumns);
            ArgumentUtility.CheckNotNull("orderedColumns", orderedColumns);

            _unionViewDefinition = unionViewDefinition;
            _selectedColumns     = selectedColumns;
            _comparedColumns     = comparedColumns;
            _orderedColumns      = orderedColumns;
        }
Exemplo n.º 16
0
        public override void SetUp()
        {
            base.SetUp();

            _factory = new SqlUnionViewScriptElementFactory();

            var property1 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column1");
            var property2 = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column2");

            var tableDefinition1 = TableDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition("SchemaName", "TableName1"),
                null,
                ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty,
                SimpleStoragePropertyDefinitionObjectMother.TimestampProperty,
                new[] { property1 });
            var tableDefinition2 = TableDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition(null, "TableName2"),
                null,
                ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty,
                SimpleStoragePropertyDefinitionObjectMother.TimestampProperty,
                new[] { property1, property2 });

            _unionViewDefinitionWithCustomSchema = UnionViewDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition("SchemaName", "UnionView1"),
                new[] { tableDefinition1 },
                ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty,
                SimpleStoragePropertyDefinitionObjectMother.TimestampProperty,
                new[] { property1 });
            _unionViewDefinitionWithDefaultSchema = UnionViewDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition(null, "UnionView2"),
                new[] { tableDefinition1, tableDefinition2 },
                ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty,
                SimpleStoragePropertyDefinitionObjectMother.TimestampProperty,
                new[] { property1, property2 });
        }
        public void SetUp()
        {
            _storageProviderDefinition = new UnitTestStorageProviderStubDefinition("SPID");

            _timestampProperty = SimpleStoragePropertyDefinitionObjectMother.TimestampProperty;
            _objectIDProperty  = ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty;
            _property1         = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column1");
            _property2         = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column2");
            _property3         = SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Column3");

            _indexes  = new[] { MockRepository.GenerateStub <IIndexDefinition>() };
            _synonyms = new[] { new EntityNameDefinition("Schema", "Test") };

            _tableDefinition1 = TableDefinitionObjectMother.Create(
                _storageProviderDefinition,
                new EntityNameDefinition(null, "Table1"),
                null,
                ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty,
                SimpleStoragePropertyDefinitionObjectMother.TimestampProperty,
                _property1);
            _tableDefinition2 = TableDefinitionObjectMother.Create(
                _storageProviderDefinition,
                new EntityNameDefinition(null, "Table2"),
                null,
                ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty,
                SimpleStoragePropertyDefinitionObjectMother.TimestampProperty,
                _property2,
                _property3);
            _unionViewDefinition = new UnionViewDefinition(
                _storageProviderDefinition,
                new EntityNameDefinition("Schema", "Test"),
                new[] { _tableDefinition1, _tableDefinition2 },
                _objectIDProperty,
                _timestampProperty,
                new[] { _property1, _property2, _property3 },
                _indexes,
                _synonyms);
        }
        public override void SetUp()
        {
            base.SetUp();

            _factory = new SqlSynonymScriptElementFactory();

            _tableDefinition1 = TableDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition("SchemaName", "TableName1"));
            _tableDefinition2 = TableDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition(null, "TableName2"));

            _unionViewDefinition1 = UnionViewDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition("SchemaName", "UnionView1"));
            _unionViewDefinition2 = UnionViewDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition(null, "UnionView2"));

            _filterViewDefinition1 = FilterViewDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition("SchemaName", "FilterView1"));
            _filterViewDefinition2 = FilterViewDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition(null, "FilterView2"));

            _emptyViewDefinition1 = EmptyViewDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition("SchemaName", "EmptyView1"));
            _emptyViewDefinition2 = EmptyViewDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition(null, "EmptyView2"));

            _synonymWithCustomSchema  = new EntityNameDefinition("SynonymSchemaName", "Synonym1");
            _synonymWithDefaultSchema = new EntityNameDefinition(null, "Synonym2");
        }
Exemplo n.º 19
0
 private void AddUnionViewDefinition(UnionViewDefinition unionViewDefinition)
 {
     AddElements(_unionViewElementFactory.GetCreateElement(unionViewDefinition), _unionViewElementFactory.GetDropElement(unionViewDefinition));
 }
Exemplo n.º 20
0
            public void VisitUnionViewDefinition(UnionViewDefinition unionViewDefinition)
            {
                ArgumentUtility.CheckNotNull("unionViewDefinition", unionViewDefinition);

                _returnValue = _unionViewDefinitionHandler(unionViewDefinition, ContinueWithNextEntity);
            }