예제 #1
0
        public override void SetUp()
        {
            base.SetUp();

            _factory = new SqlFilterViewScriptElementFactory();

            var tableDefinitionWithCustomSchema = TableDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition("SchemaName", "TableName1"));
            var tableDefinitionWithDefaultSchema = TableDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition(null, "TableName2"));

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

            _filterViewDefinitionWithCustomSchema = FilterViewDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition("SchemaName", "FilterView1"),
                tableDefinitionWithCustomSchema,
                new[] { "ClassID1" },
                ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty,
                SimpleStoragePropertyDefinitionObjectMother.TimestampProperty,
                new[] { property1 });
            _filterViewDefinitionWithDefaultSchema = FilterViewDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition(null, "FilterView2"),
                tableDefinitionWithDefaultSchema,
                new[] { "ClassID1", "ClassID2" },
                ObjectIDStoragePropertyDefinitionObjectMother.ObjectIDProperty,
                SimpleStoragePropertyDefinitionObjectMother.TimestampProperty,
                new[] { property1, property2 });
        }
        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>();
        }
        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>();
        }
예제 #4
0
        public void GetTableDefinition_FilterViewDefinition()
        {
            var filterViewDefinition = FilterViewDefinitionObjectMother.Create(
                TestDomainStorageProviderDefinition, new EntityNameDefinition(null, "FilterView"), _tableDefinition);

            var objectID = CreateObjectID(filterViewDefinition);

            _rdbmsPersistenceModelProviderStub.Stub(stub => stub.GetEntityDefinition(objectID.ClassDefinition)).Return(filterViewDefinition);

            var result = _finder.GetTableDefinition(objectID);

            Assert.That(result, Is.SameAs(_tableDefinition));
        }
        public void GetCreateScript_GetDropScript_FilterViewDefinitionAdded()
        {
            var entityDefinition = FilterViewDefinitionObjectMother.Create(SchemaGenerationFirstStorageProviderDefinition);

            _builder.AddEntityDefinition(entityDefinition);

            var createScriptResult = _builder.GetCreateScript();
            var dropScriptResult   = _builder.GetDropScript();

            Assert.That(((ScriptElementCollection)createScriptResult).Elements.Count, Is.EqualTo(1));
            Assert.That(((ScriptStatement)((ScriptElementCollection)createScriptResult).Elements[0]).Statement, Is.EqualTo("-- Create all tables"));
            Assert.That(((ScriptElementCollection)dropScriptResult).Elements.Count, Is.EqualTo(1));
            Assert.That(((ScriptStatement)((ScriptElementCollection)dropScriptResult).Elements[0]).Statement, Is.EqualTo("-- Drop all tables"));
        }
예제 #6
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> > ();
        }
예제 #8
0
        public void ResolveTable_FilterViewDefinitionWithSchemaName()
        {
            var filterViewDefinition = FilterViewDefinitionObjectMother.Create(
                TestDomainStorageProviderDefinition,
                new EntityNameDefinition("schemaName", "FilterView"),
                (IRdbmsStorageEntityDefinition)_classDefinition.StorageEntityDefinition);

            _classDefinition.SetStorageEntity(filterViewDefinition);

            _rdbmsPersistenceModelProviderStub.Stub(stub => stub.GetEntityDefinition(_classDefinition)).Return(
                _classDefinition.StorageEntityDefinition as IRdbmsStorageEntityDefinition);

            var result = (ResolvedSimpleTableInfo)_storageSpecificExpressionResolver.ResolveTable(_classDefinition, "o");

            Assert.That(result, Is.Not.Null);
            Assert.That(result.TableName, Is.EqualTo("schemaName.FilterView"));
            Assert.That(result.TableAlias, Is.EqualTo("o"));
            Assert.That(result.ItemType, Is.EqualTo(typeof(Order)));
        }
예제 #9
0
        public void GetCreateScript_GetDropScript_FilterViewDefinitionAdded()
        {
            var entityDefinition = FilterViewDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition(null, "FilterView"),
                _tableDefinition1);

            _builder.AddEntityDefinition(entityDefinition);

            var createScriptResult = _builder.GetCreateScript();
            var dropScriptResult   = _builder.GetDropScript();

            Assert.That(((ScriptElementCollection)createScriptResult).Elements.Count, Is.EqualTo(1));
            Assert.That(
                ((ScriptStatement)((ScriptElementCollection)createScriptResult).Elements[0]).Statement,
                Is.EqualTo("-- Create foreign key constraints for tables that were created above"));
            Assert.That(((ScriptElementCollection)dropScriptResult).Elements.Count, Is.EqualTo(1));
            Assert.That(
                ((ScriptStatement)((ScriptElementCollection)dropScriptResult).Elements[0]).Statement, Is.EqualTo("-- Drop foreign keys of all tables"));
        }
        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");
        }