public void IsValid() { var v = new LengthAttribute(); Assert.IsTrue(v.IsValid("12", null)); v = new LengthAttribute(5); Assert.IsTrue(v.IsValid("12", null)); Assert.IsTrue(v.IsValid(null, null)); Assert.IsTrue(v.IsValid("12345", null)); Assert.IsFalse(v.IsValid("123456", null)); Assert.IsFalse(v.IsValid(11, null)); v= new LengthAttribute(3, 6); Assert.IsTrue(v.IsValid("123", null)); Assert.IsTrue(v.IsValid("123456", null)); Assert.IsFalse(v.IsValid("12", null)); Assert.IsFalse(v.IsValid("1234567", null)); }
public void AttributeCannotBeMultiplied() { LengthAttribute lenghtAttribute = new LengthAttribute(); Assert.AreEqual(false, (AttributeUtils.AttributeAllowsMultiple(lenghtAttribute))); }
private static Attribute ConvertToLength(XmlNhvmRuleConverterArgs rule) { NhvmLength lengthRule = (NhvmLength)rule.schemaRule; int min = 0; int max = int.MaxValue; if (lengthRule.minSpecified) min = lengthRule.min; if (lengthRule.maxSpecified) max = lengthRule.max; LengthAttribute thisAttribute = new LengthAttribute(lengthRule.min, lengthRule.max); log.Info(string.Format("Converting to Length attribute with min {0}, max {1}", min, max)); if (lengthRule.message != null) { thisAttribute.Message = lengthRule.message; } AssignTagsFromString(thisAttribute, lengthRule.tags); return thisAttribute; }