public void ClassAttributes() { XmlClassMapping rm = new XmlClassMapping(GetNhvClassFor(typeof(Address))); List<Attribute> mi = new List<Attribute>(rm.GetClassAttributes()); Assert.AreEqual(0, mi.Count); rm = new XmlClassMapping(GetNhvClassFor(typeof(Suricato))); mi = new List<Attribute>(rm.GetClassAttributes()); Assert.AreEqual(1, mi.Count); }
public void MemberAttributes() { XmlClassMapping rm = new XmlClassMapping(GetNhvClassFor(typeof(Address))); MemberInfo mi = typeof(Address).GetField("floor"); List<Attribute> mas = new List<Attribute>(rm.GetMemberAttributes(mi)); Assert.AreEqual(1, mas.Count); mi = typeof(Address).GetProperty("Zip"); mas = new List<Attribute>(rm.GetMemberAttributes(mi)); Assert.AreEqual(3, mas.Count); mi = typeof(Address).GetProperty("Id"); mas = new List<Attribute>(rm.GetMemberAttributes(mi)); Assert.AreEqual(3, mas.Count); }
public static IClassMapping GetClassMapping(Type type, ValidatorMode mode) { IClassMapping result = null; switch (mode) { case ValidatorMode.UseAttribute: break; case ValidatorMode.UseXml: result = new XmlClassMapping(GetXmlDefinitionFor(type)); break; case ValidatorMode.OverrideAttributeWithXml: var xmlDefinition = GetXmlDefinitionFor(type); if (xmlDefinition != null) result = new XmlOverAttributeClassMapping(xmlDefinition); break; case ValidatorMode.OverrideXmlWithAttribute: var xmlDefinition2 = GetXmlDefinitionFor(type); if (xmlDefinition2 != null) result = new AttributeOverXmlClassMapping(xmlDefinition2); break; } return result ?? new ReflectionClassMapping(type); }
public void Members() { XmlClassMapping rm = new XmlClassMapping(GetNhvClassFor(typeof(Address))); List<MemberInfo> mi = new List<MemberInfo>(rm.GetMembers()); Assert.AreEqual(8, mi.Count); }
public void InvalidPropertyName() { var map = new XmlClassMapping(GetNhvClassFor(typeof(A))); Assert.Throws<InvalidPropertyNameException>(() => map.GetMembers()); }
public void GetEntityType() { XmlClassMapping rm = new XmlClassMapping(GetNhvClassFor(typeof(Address))); Assert.AreEqual(typeof(Address), rm.EntityType); }