Esempio n. 1
0
        public override void CanAlterSchema()
        {
            var expression = GeneratorTestHelper.GetAlterSchemaExpression();
            var currentCompatabilityMode = Generator.compatabilityMode;

            try
            {
                Generator.compatabilityMode = Runner.CompatabilityMode.STRICT;
                Shouldly.Should.Throw <DatabaseOperationNotSupportedException>(() => Generator.Generate(expression));
            }
            finally
            {
                Generator.compatabilityMode = currentCompatabilityMode;
            }
        }
        public override void CanCreateTableWithCustomColumnTypeWithCustomSchema()
        {
            var expression = GeneratorTestHelper.GetCreateTableExpression();

            expression.SchemaName = "TestSchema";
            expression.Columns[0].IsPrimaryKey = true;
            expression.Columns[1].Type         = null;
            expression.Columns[1].CustomType   = "[timestamp]";

            var result = Generator.Generate(expression);

            result.ShouldBe("CREATE TABLE [TestSchema].[TestTable1] ([TestColumn1] NVARCHAR(255) NOT NULL, [TestColumn2] [timestamp] NOT NULL, PRIMARY KEY ([TestColumn1]))");
        }
Esempio n. 3
0
        public void CanAlterDefaultConstraintWithCurrentUserAsDefault()
        {
            var expression = GeneratorTestHelper.GetAlterDefaultConstraintExpression();

            expression.DefaultValue = SystemMethods.CurrentUser;

            var expected = "ALTER TABLE [dbo].[TestTable1] ALTER [TestColumn1] DROP DEFAULT;" + Environment.NewLine +
                           "-- create alter table command to create new default constraint as string and run it" + Environment.NewLine +
                           "ALTER TABLE [dbo].[TestTable1] ALTER [TestColumn1] DEFAULT CURRENT USER;";

            var result = Generator.Generate(expression);

            result.ShouldBe(expected);
        }
Esempio n. 4
0
        public override void CanCreateIndexWithCustomSchema()
        {
            var expression = GeneratorTestHelper.GetCreateIndexExpression();

            expression.Index.SchemaName = "TestSchema";

            var result = Generator.Generate(expression);

            result.ShouldBe("CREATE INDEX [TestIndex] ON [TestSchema].[TestTable1] ([TestColumn1] ASC)");
        }
        public override void CanDeleteDataForAllRowsWithCustomSchema()
        {
            var expression = GeneratorTestHelper.GetDeleteDataAllRowsExpression();

            expression.SchemaName = "TestSchema";

            var result = Generator.Generate(expression);

            result.ShouldBe("DELETE FROM [TestSchema].[TestTable1] WHERE 1 = 1");
        }
        public override void CanCreateNullableColumnWithCustomDomainTypeAndCustomSchema()
        {
            var expression = GeneratorTestHelper.GetCreateColumnExpressionWithNullableCustomType();

            expression.SchemaName = "TestSchema";

            var result = Generator.Generate(expression);

            result.ShouldBe("ALTER TABLE [TestSchema].[TestTable1] ADD [TestColumn1] MyDomainType NULL");
        }
Esempio n. 7
0
        public void CanAlterColumnToSetNullableTrue()
        {
            var expression = GeneratorTestHelper.GetAlterColumnExpression();

            expression.Column.IsNullable = true;

            var result = Generator.Generate(expression);

            result.ShouldBe("ALTER TABLE [dbo].[TestTable1] ALTER [TestColumn1] NVARCHAR(20) NULL");
        }