public void VerifySimbolicNameSubtraction()
        {
            IValueExtractor ve = new BinaryOperatorValueExtractor(
                new NamedValueExtractor("field"),
                new NamedValueExtractor("otherfield"),
                BinaryOperatorValueExtractor.MathOperation.Subtraction);

            Assert.That(ve.SourceName, Is.EqualTo("field - otherfield"));
        }
        public void ExtractByBinaryOperatorDivision()
        {
            IValueExtractor ve = new BinaryOperatorValueExtractor(
                new NamedValueExtractor("field"),
                new NamedValueExtractor("otherfield"),
                BinaryOperatorValueExtractor.MathOperation.Division);
            var obj = new ClassTest1();

            obj.field      = 10;
            obj.otherfield = 2;
            Assert.AreEqual(5, ve.ExtractValue(obj), "Binary Extractor does not work.");
        }
        public void ExtractByBinaryOperatorUnknownOperator()
        {
            IValueExtractor ve = new BinaryOperatorValueExtractor(
                new NamedValueExtractor("field"),
                new NamedValueExtractor("otherfield"),
                (BinaryOperatorValueExtractor.MathOperation) 10000);
            var obj = new ClassTest1();

            obj.field      = 10;
            obj.otherfield = 34;
            ve.ExtractValue(obj);
        }
Ejemplo n.º 4
0
        public void DefineComplexRule1()
        {
            IValueExtractor ve = new BinaryOperatorValueExtractor(
                new NamedValueExtractor("intField1"),
                new NamedValueExtractor("intField2"),
                BinaryOperatorValueExtractor.MathOperation.Addition);
            var v = new Core.Validator();

            v.AddValidationRule(
                typeof(ProgValid1),
                ValidationUnit.CreateValidationUnit(
                    ErrorMessage.empty,
                    new RangeValueValidator(ve, 100, 1000)));
            var obj = new ProgValid1();

            obj.intField1 = 10;
            obj.intField2 = 200;

            Assert.IsTrue(v.ValidateObject(obj), "Programmatic validation does not work");
        }