Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }