public void IsValidWithGenericCollections()
        {
            var v = new SizeAttribute();
            Assert.IsTrue(v.IsValid(new HashSet<int>(), null));

            v = new SizeAttribute(1, 3);
            Assert.IsTrue(v.IsValid(new HashSet<int> { 1 }, null));
            Assert.IsTrue(v.IsValid(new HashSet<int> { 1, 2, 3 }, null));

            Assert.IsFalse(v.IsValid(new HashSet<int> { 1, 2, 3, 4, 5, 6 }, null));
        }
        public void IsValid()
        {
            var v = new SizeAttribute();
            Assert.IsTrue(v.IsValid(new int[0], null));

            v = new SizeAttribute(1, 3);
            Assert.IsTrue(v.IsValid(new int[1], null));
            Assert.IsTrue(v.IsValid(new int[3], null));
            Assert.IsTrue(v.IsValid(null, null));

            Assert.IsFalse(v.IsValid(new int[0], null));
            Assert.IsFalse(v.IsValid(new int[4], null));
            Assert.IsFalse(v.IsValid("465", null));
            Assert.IsFalse(v.IsValid(123456, null));
        }
        public void IsValid()
        {
            var v = new SizeAttribute();
            Assert.IsTrue(v.IsValid(new int[0], null));

            v = new SizeAttribute(1, 3);
            Assert.IsTrue(v.IsValid(new int[1], null));
            Assert.IsTrue(v.IsValid(new int[3], null));
            Assert.IsTrue(v.IsValid(null, null));

            Assert.IsFalse(v.IsValid(new int[0], null));
            Assert.IsFalse(v.IsValid(new int[4], null));
            // Assert.IsFalse(v.IsValid("465", null)); <= if size can validate a string then is not a big problem
            Assert.IsFalse(v.IsValid(123456, null));
        }
Exemplo n.º 4
0
        private static Attribute ConvertToSize(XmlNhvmRuleConverterArgs rule)
        {
            NhvmSize sizeRule = (NhvmSize)rule.schemaRule;
            int min = int.MinValue;
            int max = int.MaxValue;

            if (sizeRule.minSpecified)
                min = sizeRule.min;

            if (sizeRule.maxSpecified)
                max = sizeRule.max;

            log.Info(string.Format("Converting to Size attribute with min {0}, max {1}", min, max));
            SizeAttribute thisAttribute = new SizeAttribute();
            thisAttribute.Min = min;
            thisAttribute.Max = max;
            if (sizeRule.message != null)
            {
                thisAttribute.Message = sizeRule.message;
            }
            AssignTagsFromString(thisAttribute, sizeRule.tags);

            return thisAttribute;
        }