public void PropertyTypeRenameOnPropertyInherit() { // Umbraco returns nice, pascal-cased names var type1 = new TypeModel { Id = 1, Alias = "type1", ClrName = "Type1", ParentId = 0, BaseType = null, ItemType = TypeModel.ItemTypes.Content, }; type1.Properties.Add(new PropertyModel { Alias = "prop1", ClrName = "Prop1", ClrType = typeof(string), }); var types = new[] { type1 }; var code = new Dictionary<string, string> { {"assembly", @" using Umbraco.ModelsBuilder; namespace Models { public class Type2 { [ImplementPropertyType(""prop1"")] public string Renamed1 { get { return """"; } } } public partial class Type1 : Type2 { } } "} }; var parseResult = new CodeParser().Parse(code); var builder = new TextBuilder(types, parseResult); var btypes = builder.TypeModels; Assert.IsTrue(parseResult.IsPropertyIgnored("Type1", "prop1")); Assert.AreEqual(1, btypes.Count); Assert.IsTrue(btypes[0].Properties[0].IsIgnored); }
public void PropertyTypeIgnoreWildcard() { // Umbraco returns nice, pascal-cased names var type1 = new TypeModel { Id = 1, Alias = "type1", ClrName = "Type1", ParentId = 0, BaseType = null, ItemType = TypeModel.ItemTypes.Content, }; type1.Properties.Add(new PropertyModel { Alias = "prop1", ClrName = "Prop1", ClrType = typeof(string), }); type1.Properties.Add(new PropertyModel { Alias = "prop2", ClrName = "Prop2", ClrType = typeof(string), }); type1.Properties.Add(new PropertyModel { Alias = "pprop3", ClrName = "Pprop3", ClrType = typeof(string), }); var types = new[] { type1 }; var code = new Dictionary<string, string> { {"assembly", @" using Umbraco.ModelsBuilder; namespace Models { [IgnorePropertyType(""prop*"")] public partial class Type1 { } } "} }; var parseResult = new CodeParser().Parse(code); var builder = new TextBuilder(types, parseResult); var btypes = builder.TypeModels; Assert.IsTrue(parseResult.IsPropertyIgnored("Type1", "prop1")); Assert.IsTrue(parseResult.IsPropertyIgnored("Type1", "prop2")); Assert.IsFalse(parseResult.IsPropertyIgnored("Type1", "pprop3")); Assert.AreEqual(1, btypes.Count); Assert.IsTrue(btypes[0].Properties[0].IsIgnored); Assert.IsTrue(btypes[0].Properties[1].IsIgnored); Assert.IsFalse(btypes[0].Properties[2].IsIgnored); }