public void ExtractByBinaryOperatorSubtract()
 {
     IValueExtractor ve = new BinaryOperatorValueExtractor(
         new NamedValueExtractor("field"),
         new NamedValueExtractor("otherfield"),
         BinaryOperatorValueExtractor.MathOperation.Subtraction);
     var obj = new ClassTest1();
     obj.field = 10;
     obj.otherfield = 34;
     Assert.AreEqual(-24, ve.ExtractValue(obj), "Binary Extractor does not work.");
 }
        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");
        }
 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);
 }
 public void VerifySimbolicNameSubtraction()
 {
     IValueExtractor ve = new BinaryOperatorValueExtractor(
         new NamedValueExtractor("field"),
         new NamedValueExtractor("otherfield"),
         BinaryOperatorValueExtractor.MathOperation.Subtraction);
     Assert.That(ve.SourceName, Is.EqualTo("field - otherfield"));
 }