public void MemberAttributes() { ReflectionClassMapping rm = new ReflectionClassMapping(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 void Attributes() { var v = new ReflectionClassMapping(typeof(MySample)); PropertyInfo lpi = typeof(MySample).GetProperty("Str"); var ma = v.GetMemberAttributes(lpi); Assert.That(ma.Count(), Is.EqualTo(1)); Assert.That(ma.First(), Is.InstanceOf<IsNumericAttribute>()); Assert.That(ma.OfType<IsNumericAttribute>().First().Message, Is.EqualTo("Must be a number")); }