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); }
public void ToPrimaryKeyColumnNameNoCustomMethodTest() { NamingConventionsConfig config = new NamingConventionsConfig(null); NamingEngine namingEngine = new NamingEngine(config); // Component Table Name => Custom convention config.UseConventionForPrimaryKeyColumnNames(PrimaryKeyColumnNamingConvention.Custom); string result = namingEngine.ToPrimaryKeyColumnName(typeof(Customer), typeof(Customer).GetMember("ID").Single()); }