Esempio n. 1
0
        /// <summary>
        /// Evaluates the <see cref="BusinessObjectDTO"/> passed in to see if it matches the criteria that have been set up
        /// </summary>
        /// <param name="dto">The <see cref="BusinessObjectDTO"/> to check for a match against the criteria</param>
        /// <returns>True if the <see cref="BusinessObjectDTO"/> matches the criteria, false if it does not</returns>
        public virtual bool IsMatch(BusinessObjectDTO dto)
        {
            if (IsComposite())
            {
                switch (LogicalOperator)
                {
                case LogicalOp.And:
                    return(LeftCriteria.IsMatch(dto) && RightCriteria.IsMatch(dto));

                case LogicalOp.Or:
                    return(LeftCriteria.IsMatch(dto) || RightCriteria.IsMatch(dto));

                case LogicalOp.Not:
                    return(!RightCriteria.IsMatch(dto));
                }
            }


            object leftValue = dto.Props[Field.PropertyName.ToUpper()];
            string className = dto.ClassDefName;

            return(CheckValueAgainstSingleCriteria(leftValue, className));
        }
Esempio n. 2
0
        public void TestIsMatch_OnBusinessObjectDTO_TwoProps_Not()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            MyBO.LoadClassDefWithBoolean();
            MyBO bo = new MyBO();
            bo.TestBoolean = false;
            BusinessObjectDTO dto = new BusinessObjectDTO(bo);

            Criteria notCriteria = new Criteria(null, Criteria.LogicalOp.Not, new Criteria("TestBoolean", Criteria.ComparisonOp.Equals, true));

            //---------------Execute Test ----------------------
            bool isMatch = notCriteria.IsMatch(dto);
            //---------------Test Result -----------------------
            Assert.IsTrue(isMatch, "The object should be a match since it matches the criteria given.");
        }
Esempio n. 3
0
        public void TestIsMatch_OnBusinessObjectDTO_TwoProps_Or()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            ContactPersonTestBO.LoadDefaultClassDef();
            ContactPersonTestBO cp = new ContactPersonTestBO();
            DateTime dob = DateTime.Now;
            cp.DateOfBirth = dob;
            string surname = Guid.NewGuid().ToString("N");
            cp.Surname = surname;
            cp.Save();
            Criteria dobCriteria = new Criteria("DateOfBirth", Criteria.ComparisonOp.Equals, dob.AddDays(2));
            Criteria nameCriteria = new Criteria("Surname", Criteria.ComparisonOp.Equals, surname);
            BusinessObjectDTO dto = new BusinessObjectDTO(cp);

            //---------------Execute Test ----------------------
            Criteria twoPropCriteria = new Criteria(dobCriteria, Criteria.LogicalOp.Or, nameCriteria);
            bool isMatch = twoPropCriteria.IsMatch(dto);
            //---------------Test Result -----------------------
            Assert.IsTrue(isMatch, "The object should be a match since it matches the criteria given.");
            //---------------Tear Down -------------------------
        }
Esempio n. 4
0
        public void TestIsMatch_OnBusinessObjectDTO_OneProp_Like()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            ContactPersonTestBO.LoadDefaultClassDef();
            ContactPersonTestBO cp = new ContactPersonTestBO();
            cp.Surname = "This is MyValue Surname";
            BusinessObjectDTO dto = new BusinessObjectDTO(cp);

            //---------------Execute Test ----------------------
            Criteria criteria = new Criteria("Surname", Criteria.ComparisonOp.Like, "%MyValue%");
            bool isMatch = criteria.IsMatch(dto);
            //---------------Test Result -----------------------
            Assert.IsTrue(isMatch, "The object should be a match since it matches the criteria given.");
            //---------------Tear Down -------------------------          
        }