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

            _factory = new SqlTableScriptElementFactory();

            var column1   = new ColumnDefinition("Column1", StorageTypeInformationObjectMother.CreateVarchar100StorageTypeInformation(false), false);
            var column2   = new ColumnDefinition("Column2", StorageTypeInformationObjectMother.CreateBitStorageTypeInformation(true), false);
            var property1 = new SimpleStoragePropertyDefinition(typeof(string), column1);
            var property2 = new SimpleStoragePropertyDefinition(typeof(bool), column2);

            var idColumn         = new ColumnDefinition("ID", StorageTypeInformationObjectMother.CreateUniqueIdentifierStorageTypeInformation(false), true);
            var classIDColumn    = new ColumnDefinition("ClassID", StorageTypeInformationObjectMother.CreateVarchar100StorageTypeInformation(true), false);
            var objectIDProperty = new ObjectIDStoragePropertyDefinition(
                new SimpleStoragePropertyDefinition(typeof(object), idColumn),
                new SimpleStoragePropertyDefinition(typeof(string), classIDColumn));
            var timestampColumn   = new ColumnDefinition("Timestamp", StorageTypeInformationObjectMother.CreateDateTimeStorageTypeInformation(true), false);
            var timestampProperty = new SimpleStoragePropertyDefinition(typeof(object), timestampColumn);

            _tableDefinitionWithoutPrimaryKeyConstraint = TableDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition("SchemaName", "EntityName"),
                null,
                objectIDProperty,
                timestampProperty,
                property1);

            _tableDefinitionWithClusteredPrimaryKeyConstraint = TableDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition("SchemaName", "EntityName"),
                null,
                objectIDProperty,
                timestampProperty,
                new[] { property1, property2 },
                new ITableConstraintDefinition[] { new PrimaryKeyConstraintDefinition("PKName", true, new[] { column1 }) });

            _tableDefinitionWithNonClusteredPrimaryKeyConstraint = TableDefinitionObjectMother.Create(
                SchemaGenerationFirstStorageProviderDefinition,
                new EntityNameDefinition(null, "EntityName"),
                null,
                objectIDProperty,
                timestampProperty,
                new[] { property1, property2 },
                new ITableConstraintDefinition[] { new PrimaryKeyConstraintDefinition("PKName", false, new[] { column1, column2 }) });
        }