コード例 #1
0
        public void WhenDefaultSchemaConventionIsChangedAndSchemaIsNotSetThenSetSchema()
        {
            var expression = new CreateForeignKeyExpression();

            var processed = expression.Apply(ConventionSets.WithSchemaName);

            Assert.That(processed.ForeignKey.ForeignTableSchema, Is.EqualTo("testdefault"));
            Assert.That(processed.ForeignKey.PrimaryTableSchema, Is.EqualTo("testdefault"));
        }
コード例 #2
0
        public void WhenDefaultSchemaConventionIsAppliedAndSchemaIsNotSetThenSchemaShouldBeNull()
        {
            var expression = new CreateForeignKeyExpression();

            var processed = expression.Apply(ConventionSets.NoSchemaName);

            Assert.That(processed.ForeignKey.ForeignTableSchema, Is.Null);
            Assert.That(processed.ForeignKey.PrimaryTableSchema, Is.Null);
        }
コード例 #3
0
        public void WhenDefaultSchemaConventionIsAppliedAndSchemaIsSetThenSchemaShouldNotBeChanged()
        {
            var expression = new CreateForeignKeyExpression()
            {
                ForeignKey =
                {
                    ForeignTableSchema = "testschema",
                    PrimaryTableSchema = "testschema"
                },
            };

            var processed = expression.Apply(ConventionSets.WithSchemaName);

            Assert.That(processed.ForeignKey.ForeignTableSchema, Is.EqualTo("testschema"));
            Assert.That(processed.ForeignKey.PrimaryTableSchema, Is.EqualTo("testschema"));
        }
コード例 #4
0
        public void GetForeignKeyNameReturnsValidForeignKeyNameForComplexForeignKey()
        {
            var expr = new CreateForeignKeyExpression()
            {
                ForeignKey =
                {
                    ForeignTable   = "Users",
                    ForeignColumns = new[] { "ColumnA","ColumnB"          },
                    PrimaryTable   = "Groups",
                    PrimaryColumns = new[] { "ColumnC","ColumnD"          }
                }
            };

            var processed = expr.Apply(ConventionSets.NoSchemaName);

            processed.ForeignKey.Name.ShouldBe("FK_Users_ColumnA_ColumnB_Groups_ColumnC_ColumnD");
        }
コード例 #5
0
        public static CreateForeignKeyExpression GetCreateMultiColumnForeignKeyExpression()
        {
            var expression = new CreateForeignKeyExpression
            {
                ForeignKey =
                {
                    PrimaryTable   = TestTableName2,
                    ForeignTable   = TestTableName1,
                    PrimaryColumns = new[] { TestColumnName2,"TestColumn4"          },
                    ForeignColumns = new[] { TestColumnName1,"TestColumn3"          }
                }
            };

            var processed = expression.Apply(ConventionSets.NoSchemaName);

            return(processed);
        }