public void IsValid()
 {
     var v = new MinAttribute();
     Assert.IsTrue(v.IsValid(0, null));
     v = new MinAttribute(2);
     Assert.IsTrue(v.IsValid(3, null));
     Assert.IsTrue(v.IsValid(2, null));
     Assert.IsTrue(v.IsValid((decimal) 200.0, null));
     Assert.IsTrue(v.IsValid(null, null));
     Assert.IsTrue(v.IsValid("5", null));
     Assert.IsTrue(v.IsValid((long) int.MaxValue + 1, null));
     Assert.IsFalse(v.IsValid(1, null));
     Assert.IsFalse(v.IsValid("aaa", null));
     Assert.IsFalse(v.IsValid(new object(), null));
 }
        public void Extreme()
        {
            var v = new MinAttribute {Value = -10000};
            Assert.IsTrue(v.IsValid(-10000, null));
            Assert.IsTrue(v.IsValid(-10000L, null));
            Assert.IsTrue(v.IsValid(123UL, null));
            Assert.IsTrue(v.IsValid(123U, null));
            Assert.IsTrue(v.IsValid((ushort) 5, null));
            Assert.IsTrue(v.IsValid((short) 5, null));
            Assert.IsTrue(v.IsValid(true, null));
            Assert.IsTrue(v.IsValid((byte) 100, null));
            Assert.IsTrue(v.IsValid((sbyte) 100, null));
            Assert.IsTrue(v.IsValid(AEnum.A, null));
            Assert.IsTrue(v.IsValid(CarOptions.Spoiler | CarOptions.FogLights, null));
            Assert.IsTrue(v.IsValid('A', null));
            Assert.IsTrue(v.IsValid(-9999.99999f, null));
            Assert.IsTrue(v.IsValid(-9999.9999999999999999999999999d, null));

            Assert.IsFalse(v.IsValid(decimal.MinValue, null));
            Assert.IsFalse(v.IsValid(decimal.MinValue.ToString(), null));
            Assert.IsFalse(v.IsValid(double.MinValue, null));
            Assert.IsFalse(v.IsValid(double.MinValue + "9", null));
        }
Exemplo n.º 3
0
        private static Attribute ConvertToMin(XmlNhvmRuleConverterArgs rule)
        {
            NhvmMin minRule = (NhvmMin)rule.schemaRule;
            long value = 0;

            if (minRule.valueSpecified)
                value = minRule.value;

            log.Info(string.Format("Converting to Min attribute with value {0}", value));
            MinAttribute thisAttribute = new MinAttribute();
            thisAttribute.Value = value;

            if (minRule.message != null)
            {
                thisAttribute.Message = minRule.message;
            }
            AssignTagsFromString(thisAttribute, minRule.tags);

            return thisAttribute;
        }