public void ToElementTableNameTest() { NamingConventionsConfig config = new NamingConventionsConfig(null); NamingEngine namingEngine = new NamingEngine(config); // Element Table Name => ElementName config.UseConventionForTableNames(TablesNamingConvention.CamelCase); config.UseConventionForElementTableNames(ElementsTableNamingConvention.ElementTypeName); string result = namingEngine.ToElementTableName(typeof(ProductsOrder), typeof(OrderItem), typeof(ProductsOrder).GetMember("Items").Single()); Assert.AreEqual("orderItem", result); // Element Table Name => EntityName & ElementName config.UseConventionForTableNames(TablesNamingConvention.PascalCase); config.UseConventionForElementTableNames(ElementsTableNamingConvention.EntityName_ElementName); result = namingEngine.ToElementTableName(typeof(ProductsOrder), typeof(OrderItem), typeof(ProductsOrder).GetMember("Items").Single()); Assert.AreEqual("ProductsOrder_OrderItem", result); // Element Table Name => EntityName & Property Name config.UseConventionForTableNames(TablesNamingConvention.Lowercase); config.UseConventionForElementTableNames(ElementsTableNamingConvention.EntityName_PropertyName); result = namingEngine.ToElementTableName(typeof(ProductsOrder), typeof(OrderItem), typeof(ProductsOrder).GetMember("Items").Single()); Assert.AreEqual("products_order_items", result); // Element Table Name => EntityName & Property Name config.UseConventionForTableNames(TablesNamingConvention.CamelCase); config.UseConventionForElementTableNames(ElementsTableNamingConvention.EntityNameElementName); result = namingEngine.ToElementTableName(typeof(ProductsOrder), typeof(OrderItem), typeof(ProductsOrder).GetMember("Items").Single()); Assert.AreEqual("productsOrderOrderItem", result); // Element Table Name => EntityName & Property Name config.UseConventionForTableNames(TablesNamingConvention.Uppercase); config.UseConventionForElementTableNames(ElementsTableNamingConvention.EntityNamePropertyName); result = namingEngine.ToElementTableName(typeof(ProductsOrder), typeof(OrderItem), typeof(ProductsOrder).GetMember("Items").Single()); Assert.AreEqual("PRODUCTS_ORDER_ITEMS", result); // Element Table Name => EntityName & Property Name config.UseConventionForTableNames(TablesNamingConvention.CamelCase); config.UseConventionForElementTableNames(ElementsTableNamingConvention.PropertyName); result = namingEngine.ToElementTableName(typeof(ProductsOrder), typeof(OrderItem), typeof(ProductsOrder).GetMember("Items").Single()); Assert.AreEqual("items", result); // Element Table Name => EntityName & Property Name config.UseConventionForTableNames(TablesNamingConvention.CamelCase); config.UseCustomConventionForElementTableNames((e, c, p) => { Assert.AreEqual(typeof(ProductsOrder), e); Assert.AreEqual(typeof(OrderItem), c); Assert.AreEqual(typeof(ProductsOrder).GetMember("Items").Single(), p); return "CustomElementTableName"; }); result = namingEngine.ToElementTableName(typeof(ProductsOrder), typeof(OrderItem), typeof(ProductsOrder).GetMember("Items").Single()); Assert.AreEqual("CustomElementTableName", result); }
public void ToElementTableNameNoCustomMethodTest() { NamingConventionsConfig config = new NamingConventionsConfig(null); NamingEngine namingEngine = new NamingEngine(config); // Element Table Name => Custom convention config.UseConventionForElementTableNames(ElementsTableNamingConvention.Custom); string result = namingEngine.ToElementTableName(typeof(ProductsOrder), typeof(OrderItem), typeof(ProductsOrder).GetMember("Items").Single()); }