public void ToForeignKeyNameEntityNameIdNameTest()
        {
            NamingConventionsConfig config = new NamingConventionsConfig(null);
            NamingEngine namingEngine = new NamingEngine(config);

            config.UseConventionForPrimaryKeyColumnNames(PrimaryKeyColumnNamingConvention.EntityName_IdPropertyName);
            config.UseConventionForForeignKeyColumnNames(ForeignKeyColumnNamingConvention.PropertyNameIdPropertyName);
            config.UseConventionForConstraintNames(ConstraintNamingConvention.Lowercase);

            // Foreign Key Name => Default
            config.UseConventionForForeignKeyNames(ForeignKeyNamingConvention.Default);
            string result = namingEngine.ToForeignKeyName(typeof(City), typeof(State), typeof(City).GetMember("State").Single(), typeof(State).GetMember("ID").Single());
            Assert.IsTrue(string.IsNullOrEmpty(result));

            // Foreign Key Name => FK_FKTable_PKTable
            config.UseConventionForForeignKeyNames(ForeignKeyNamingConvention.FK_FKTable_PKTable);
            result = namingEngine.ToForeignKeyName(typeof(City), typeof(State), typeof(City).GetMember("State").Single(), typeof(State).GetMember("ID").Single());
            Assert.AreEqual("fk__city__state", result);

            // Foreign Key Name => FK_FKTable_PKTable_PKColumn
            config.UseConventionForForeignKeyNames(ForeignKeyNamingConvention.FK_FKTable_PKTable_FKColumn);
            result = namingEngine.ToForeignKeyName(typeof(City), typeof(State), typeof(City).GetMember("State").Single(), typeof(State).GetMember("ID").Single());
            Assert.AreEqual("fk__city__state__state_id", result);

            // Foreign Key Name => FKTable_PKTable_FK
            config.UseConventionForForeignKeyNames(ForeignKeyNamingConvention.FKTable_PKTable_FK);
            result = namingEngine.ToForeignKeyName(typeof(City), typeof(State), typeof(City).GetMember("State").Single(), typeof(State).GetMember("ID").Single());
            Assert.AreEqual("city__state__fk", result);

            // Foreign Key Name => FKTable_PKTable_PKColumn_FK
            config.UseConventionForForeignKeyNames(ForeignKeyNamingConvention.FKTable_PKTable_FKColumn_FK);
            result = namingEngine.ToForeignKeyName(typeof(City), typeof(State), typeof(City).GetMember("State").Single(), typeof(State).GetMember("ID").Single());
            Assert.AreEqual("city__state__state_id__fk", result);

            // Foreign Key Name => Custom
            config.UseCustomConventionForForeignKeyNames((s, t, f, i) =>
            {
                Assert.AreEqual(typeof(City), s);
                Assert.AreEqual(typeof(State), t);
                Assert.AreEqual(typeof(City).GetMember("State").Single(), f);
                Assert.AreEqual(typeof(State).GetMember("ID").Single(), i);

                return "CustomForeignKeyName";
            });
            result = namingEngine.ToForeignKeyName(typeof(City), typeof(State), typeof(City).GetMember("State").Single(), typeof(State).GetMember("ID").Single());
            Assert.AreEqual("CustomForeignKeyName", result);
        }
        public void ToManyToManyForeignKeyNameTest()
        {
            NamingConventionsConfig config = new NamingConventionsConfig(null);
            NamingEngine namingEngine = new NamingEngine(config);

            config.UseConventionForComponentTableNames(ComponentsTableNamingConvention.EntityNameRelationshipName);
            config
               .UseConventionForPrimaryKeyColumnNames(PrimaryKeyColumnNamingConvention.EntityName_IdPropertyName)
               .UseConventionForConstraintNames(ConstraintNamingConvention.Lowercase);

            // Foreign Key Name => Default
            config.UseConventionForForeignKeyNames(ForeignKeyNamingConvention.Default);
            string result = namingEngine.ToManyToManyForeignKeyName(typeof(Product), typeof(Category), typeof(Category), typeof(ProductsOrder).GetMember("ID").Single());
            Assert.IsTrue(string.IsNullOrEmpty(result));

            // Foreign Key Name => FK_FKTable_PKTable
            config.UseConventionForForeignKeyNames(ForeignKeyNamingConvention.FK_FKTable_PKTable);
            result = namingEngine.ToManyToManyForeignKeyName(typeof(Product), typeof(Category), typeof(Category), typeof(ProductsOrder).GetMember("ID").Single());
            Assert.AreEqual("fk__category_product__category", result);

            // Foreign Key Name => FK_FKTable_PKTable_PKColumn
            config.UseConventionForForeignKeyNames(ForeignKeyNamingConvention.FK_FKTable_PKTable_FKColumn);
            result = namingEngine.ToManyToManyForeignKeyName(typeof(Product), typeof(Category), typeof(Category), typeof(ProductsOrder).GetMember("ID").Single());
            Assert.AreEqual("fk__category_product__category__id", result);

            // Foreign Key Name => FKTable_PKTable_FK
            config.UseConventionForForeignKeyNames(ForeignKeyNamingConvention.FKTable_PKTable_FK);
            result = namingEngine.ToManyToManyForeignKeyName(typeof(Product), typeof(Category), typeof(Category), typeof(ProductsOrder).GetMember("ID").Single());
            Assert.AreEqual("category_product__category__fk", result);

            // Foreign Key Name => FKTable_PKTable_PKColumn_FK
            config.UseConventionForForeignKeyNames(ForeignKeyNamingConvention.FKTable_PKTable_FKColumn_FK);
            result = namingEngine.ToManyToManyForeignKeyName(typeof(Product), typeof(Category), typeof(Category), typeof(ProductsOrder).GetMember("ID").Single());
            Assert.AreEqual("category_product__category__id__fk", result);

            // Foreign Key Name => Custom
            config.UseCustomConventionForForeignKeyNames((s, t, f, i) =>
            {
                Assert.AreEqual(typeof(Product), s);
                Assert.AreEqual(typeof(Category), t);
                Assert.AreEqual(typeof(Category), f);
                Assert.AreEqual(typeof(ProductsOrder).GetMember("ID").Single(), i);

                return "CustomForeignKeyName";
            });
            result = namingEngine.ToManyToManyForeignKeyName(typeof(Product), typeof(Category), typeof(Category), typeof(ProductsOrder).GetMember("ID").Single());
            Assert.AreEqual("CustomForeignKeyName", result);
        }
        public void ToComponentForeignKeyNameTest()
        {
            NamingConventionsConfig config = new NamingConventionsConfig(null);
            NamingEngine namingEngine = new NamingEngine(config);

            config.UseConventionForComponentTableNames(ComponentsTableNamingConvention.EntityNameComponentName);
            config.UseConventionForPrimaryKeyColumnNames(PrimaryKeyColumnNamingConvention.Default);
            config.UseConventionForConstraintNames(ConstraintNamingConvention.Uppercase);

            // Foreign Key Name => Default
            config.UseConventionForForeignKeyNames(ForeignKeyNamingConvention.Default);
            string result = namingEngine.ToComponentForeignKeyName(typeof(Telephone), typeof(Customer), typeof(Customer).GetMember("Telephones").Single(), typeof(Customer).GetMember("ID").Single());
            Assert.IsTrue(string.IsNullOrEmpty(result));

            // Foreign Key Name => FK_FKTable_PKTable
            config.UseConventionForForeignKeyNames(ForeignKeyNamingConvention.FK_FKTable_PKTable);
            result = namingEngine.ToComponentForeignKeyName(typeof(Telephone), typeof(Customer), typeof(Customer).GetMember("Telephones").Single(), typeof(Customer).GetMember("ID").Single());
            Assert.AreEqual("FK__CUSTOMER_TELEPHONE__CUSTOMER", result);

            // Foreign Key Name => FK_FKTable_PKTable_PKColumn
            config.UseConventionForForeignKeyNames(ForeignKeyNamingConvention.FK_FKTable_PKTable_FKColumn);
            result = namingEngine.ToComponentForeignKeyName(typeof(Telephone), typeof(Customer), typeof(Customer).GetMember("Telephones").Single(), typeof(Customer).GetMember("ID").Single());
            Assert.AreEqual("FK__CUSTOMER_TELEPHONE__CUSTOMER__ID", result);

            // Foreign Key Name => FKTable_PKTable_FK
            config.UseConventionForForeignKeyNames(ForeignKeyNamingConvention.FKTable_PKTable_FK);
            result = namingEngine.ToComponentForeignKeyName(typeof(Telephone), typeof(Customer), typeof(Customer).GetMember("Telephones").Single(), typeof(Customer).GetMember("ID").Single());
            Assert.AreEqual("CUSTOMER_TELEPHONE__CUSTOMER__FK", result);

            // Foreign Key Name => FKTable_PKTable_PKColumn_FK
            config.UseConventionForForeignKeyNames(ForeignKeyNamingConvention.FKTable_PKTable_FKColumn_FK);
            result = namingEngine.ToComponentForeignKeyName(typeof(Telephone), typeof(Customer), typeof(Customer).GetMember("Telephones").Single(), typeof(Customer).GetMember("ID").Single());
            Assert.AreEqual("CUSTOMER_TELEPHONE__CUSTOMER__ID__FK", result);

            // Foreign Key Name => FKTable_PKTable_PKColumn_FK
            config.UseCustomConventionForForeignKeyNames((s, t, f, i) =>
                {
                    Assert.AreEqual(typeof(Customer), s);
                    Assert.AreEqual(typeof(Telephone), t);
                    Assert.AreEqual(typeof(Customer).GetMember("Telephones").Single(), f);
                    Assert.AreEqual(typeof(Customer).GetMember("ID").Single(), i);

                    return "CustomForeignKeyName";
                });
            result = namingEngine.ToComponentForeignKeyName(typeof(Customer), typeof(Telephone), typeof(Customer).GetMember("Telephones").Single(), typeof(Customer).GetMember("ID").Single());
            Assert.AreEqual("CustomForeignKeyName", result);
        }