public void ToColumnNameNoCustomMethodTest()
        {
            NamingConventionsConfig config = new NamingConventionsConfig(null);
            NamingEngine namingEngine = new NamingEngine(config);
            var memberInfo = typeof(Customer).GetMember("FirstName").FirstOrDefault();

            // Component Table Name => Custom convention
            config.UseConventionForColumnNames(ColumnsNamingConvention.Custom);
            string result = namingEngine.ToColumnName(memberInfo);
        }
        public void ToColumnNameTest()
        {
            NamingConventionsConfig config = new NamingConventionsConfig(null);
            NamingEngine namingEngine = new NamingEngine(config);
            var memberInfo = typeof(Customer).GetMember("FirstName").FirstOrDefault();

            // Column Name => Default
            config.UseConventionForColumnNames(ColumnsNamingConvention.Default);
            string result = namingEngine.ToColumnName(memberInfo);
            Assert.AreEqual("FirstName", result);

            // Column Name => Camel Case
            config.UseConventionForColumnNames(ColumnsNamingConvention.CamelCase);
            result = namingEngine.ToColumnName(memberInfo);
            Assert.AreEqual("firstName", result);

            // Column Name => Pascal Case
            config.UseConventionForColumnNames(ColumnsNamingConvention.PascalCase);
            result = namingEngine.ToColumnName(memberInfo);
            Assert.AreEqual("FirstName", result);

            // Column Name => Uppercase Underscore Separated
            config.UseConventionForColumnNames(ColumnsNamingConvention.Uppercase);
            result = namingEngine.ToColumnName(memberInfo);
            Assert.AreEqual("FIRST_NAME", result);

            // Column Name => Lowercase Underscore Separated
            config.UseConventionForColumnNames(ColumnsNamingConvention.Lowercase);
            result = namingEngine.ToColumnName(memberInfo);
            Assert.AreEqual("first_name", result);

            // Column Name => Custom
            config.UseCustomConventionForColumnNames(m =>
                {
                    Assert.AreEqual(memberInfo, m);

                    return "CustomColumnName";
                });
            result = namingEngine.ToColumnName(memberInfo);
            Assert.AreEqual("CustomColumnName", result);
        }
        public void ToComponentColumNameComponentNamePropertyNameTest()
        {
            NamingConventionsConfig config = new NamingConventionsConfig(null);
            NamingEngine namingEngine = new NamingEngine(config);

            var parentProperty = typeof(Customer).GetMember("Address").FirstOrDefault();
            var childProperty = typeof(Address).GetMember("Street").FirstOrDefault();

            // Column Name => Default
            config.UseConventionForColumnNames(ColumnsNamingConvention.Default);
            config.UseConventionForComponentColumnNames(ComponentsColumnsNamingConvention.ComponentNamePropertyName);
            string result = namingEngine.ToComponentColumnName(childProperty, parentProperty);
            Assert.AreEqual("AddressStreet", result);

            // Column Name => Camel Case
            config.UseConventionForColumnNames(ColumnsNamingConvention.CamelCase);
            result = namingEngine.ToComponentColumnName(childProperty, parentProperty);
            Assert.AreEqual("addressStreet", result);

            // Column Name => Pascal Case
            config.UseConventionForColumnNames(ColumnsNamingConvention.PascalCase);
            result = namingEngine.ToComponentColumnName(childProperty, parentProperty);
            Assert.AreEqual("AddressStreet", result);

            // Column Name => Uppercase Underscore Separated
            config.UseConventionForColumnNames(ColumnsNamingConvention.Uppercase);
            result = namingEngine.ToComponentColumnName(childProperty, parentProperty);
            Assert.AreEqual("ADDRESS_STREET", result);

            // Column Name => Lowercase Underscore Separated
            config.UseConventionForColumnNames(ColumnsNamingConvention.Lowercase);
            result = namingEngine.ToComponentColumnName(childProperty, parentProperty);
            Assert.AreEqual("address_street", result);

            // Column Name => Custom
            config.UseCustomConventionForComponentColumnNames((c, p) =>
            {
                Assert.AreEqual(childProperty, p);
                Assert.AreEqual(typeof(Address), c);

                return "CustomColumnName";
            });
            result = namingEngine.ToComponentColumnName(childProperty, parentProperty);
            Assert.AreEqual("CustomColumnName", result);
        }
        public void ToManyToManyForeignKeyColumnNameTest()
        {
            NamingConventionsConfig config = new NamingConventionsConfig(null);
            NamingEngine namingEngine = new NamingEngine(config);

            // Column Name => Default
            config.UseConventionForColumnNames(ColumnsNamingConvention.Uppercase);
            config.UseConventionForForeignKeyColumnNames(ForeignKeyColumnNamingConvention.Default);
            string result = namingEngine.ToManyToManyForeignKeyColumnName(typeof(Product), typeof(Product).GetMember("ID").Single());
            Assert.AreEqual("PRODUCT_KEY", result);

            // Column Name => Target EntityName
            config.UseConventionForColumnNames(ColumnsNamingConvention.PascalCase);
            config.UseConventionForForeignKeyColumnNames(ForeignKeyColumnNamingConvention.Default);
            result = namingEngine.ToManyToManyForeignKeyColumnName(typeof(Product), typeof(Product).GetMember("ID").Single());
            Assert.AreEqual("Product_Key", result);

            // Column Name => Target EntityName & IdPropertyName
            config.UseConventionForColumnNames(ColumnsNamingConvention.Lowercase);
            config.UseConventionForForeignKeyColumnNames(ForeignKeyColumnNamingConvention.PropertyName_IdPropertyName);
            result = namingEngine.ToManyToManyForeignKeyColumnName(typeof(Product), typeof(Product).GetMember("ID").Single());
            Assert.AreEqual("product_id", result);

            // Column Name => Target & IdPropertyName
            config.UseConventionForColumnNames(ColumnsNamingConvention.Uppercase);
            config.UseConventionForForeignKeyColumnNames(ForeignKeyColumnNamingConvention.PropertyNameIdPropertyName);
            result = namingEngine.ToManyToManyForeignKeyColumnName(typeof(Product), typeof(Product).GetMember("ID").Single());
            Assert.AreEqual("PRODUCT_ID", result);

            // Column Name => Custom
            config.UseCustomConventionForForeignKeyColumnNames((e, i) =>
            {
                Assert.AreEqual(typeof(Product), e);
                Assert.AreEqual(typeof(Product).GetMember("ID").Single(), i);

                return "CustomForeignKeyColumnName";
            });
            result = namingEngine.ToForeignKeyColumnName(typeof(Product), typeof(Product).GetMember("ID").Single());
            Assert.AreEqual("CustomForeignKeyColumnName", result);
        }
        public void ToElementValueColumNameTest()
        {
            NamingConventionsConfig config = new NamingConventionsConfig(null);
            NamingEngine namingEngine = new NamingEngine(config);
            var memberInfo = typeof(ElementModel.Element).GetMember("DictionaryLongString").FirstOrDefault();

            // Column Name => Default
            config.UseConventionForColumnNames(ColumnsNamingConvention.Default);
            string result = namingEngine.ToElementValueColumnName(memberInfo);
            Assert.AreEqual("Value", result);

            // Column Name => Camel Case
            config.UseConventionForColumnNames(ColumnsNamingConvention.CamelCase);
            result = namingEngine.ToElementValueColumnName(memberInfo);
            Assert.AreEqual("value", result);

            // Column Name => Pascal Case
            config.UseConventionForColumnNames(ColumnsNamingConvention.PascalCase);
            result = namingEngine.ToElementValueColumnName(memberInfo);
            Assert.AreEqual("Value", result);

            // Column Name => Uppercase Underscore Separated
            config.UseConventionForColumnNames(ColumnsNamingConvention.Uppercase);
            result = namingEngine.ToElementValueColumnName(memberInfo);
            Assert.AreEqual("VALUE", result);

            // Column Name => Lowercase Underscore Separated
            config.UseConventionForColumnNames(ColumnsNamingConvention.Lowercase);
            result = namingEngine.ToElementValueColumnName(memberInfo);
            Assert.AreEqual("value", result);

            // Column Name => Custom
            config.UseCustomConventionForColumnNames(m =>
            {
                Assert.AreEqual(memberInfo, m);

                return "CustomColumnName";
            });
            result = namingEngine.ToElementValueColumnName(memberInfo);
            Assert.AreEqual("CustomColumnName", result);
        }
        public void ToComponentColumNameCustomTest()
        {
            NamingConventionsConfig config = new NamingConventionsConfig(null);
            NamingEngine namingEngine = new NamingEngine(config);

            var parentProperty = typeof(Customer).GetMember("Address").FirstOrDefault();
            var childProperty = typeof(Address).GetMember("Street").FirstOrDefault();

            // Column Name => Default
            config.UseConventionForColumnNames(ColumnsNamingConvention.Default);
            config
                .UseCustomConventionForComponentColumnNames((e, m) =>
                {
                    Assert.AreEqual(typeof(Address), e);
                    Assert.AreEqual(childProperty, m);

                    return "CustomColumnName";
                });
            string result = namingEngine.ToComponentColumnName(childProperty, parentProperty);

            Assert.AreEqual("CustomColumnName", result);
        }
        public void ToPrimaryKeyColumnNameTest()
        {
            NamingConventionsConfig config = new NamingConventionsConfig(null);
            NamingEngine namingEngine = new NamingEngine(config);

            config.UseConventionForColumnNames(ColumnsNamingConvention.CamelCase);

            // Column Name => Default
            config.UseConventionForPrimaryKeyColumnNames(PrimaryKeyColumnNamingConvention.Default);
            string result = namingEngine.ToPrimaryKeyColumnName(typeof(Customer), typeof(Customer).GetMember("ID").Single());
            Assert.AreEqual("id", result);

            // Column Name => EntityName & IdPropertyName
            config.UseConventionForPrimaryKeyColumnNames(PrimaryKeyColumnNamingConvention.EntityName_IdPropertyName);
            result = namingEngine.ToPrimaryKeyColumnName(typeof(Customer), typeof(Customer).GetMember("ID").Single());
            Assert.AreEqual("customer_id", result);

            // Column Name => EntityName & IdPropertyName
            config.UseConventionForPrimaryKeyColumnNames(PrimaryKeyColumnNamingConvention.EntityNameIdPropertyName);
            result = namingEngine.ToPrimaryKeyColumnName(typeof(Customer), typeof(Customer).GetMember("ID").Single());
            Assert.AreEqual("customerId", result);

            // Column Name => Custom
            config.UseCustomConventionForPrimaryKeyColumnNames((e, i) =>
                {
                    Assert.AreEqual(typeof(Customer), e);
                    Assert.AreEqual(typeof(Customer).GetMember("ID").Single(), i);

                    return "CustomPrimaryKeyColumnName";
                });
            result = namingEngine.ToPrimaryKeyColumnName(typeof(Customer), typeof(Customer).GetMember("ID").Single());
            Assert.AreEqual("CustomPrimaryKeyColumnName", result);
        }