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 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); }