Пример #1
0
        public void BinaryFilterOperators(object operandFirst1, object operandFirst2, FilterOperator filterOp, object expectedResult)
        {
            LiteralOperand loperand1 = new LiteralOperand();
            LiteralOperand loperand2 = new LiteralOperand();

            loperand1.Value = new Variant(operandFirst1);
            if (filterOp == FilterOperator.Cast)
            {
                NodeId uintNoid = new NodeId(operandFirst2, 0);
                loperand2.Value = new Variant(uintNoid);
            }
            else
            {
                loperand2.Value = new Variant(operandFirst2);
            }


            ContentFilterElement filterElement = new ContentFilterElement();

            filterElement.FilterOperator = filterOp;
            filterElement.SetOperands(new List <LiteralOperand>()
            {
                loperand1, loperand2
            });
            Filter.WhereClause.Elements = new[] { filterElement };

            // apply filter.
            object result = Filter.WhereClause.Evaluate(FilterContext, TestFilterTarget);

            Assert.AreEqual(expectedResult, result);
        }
Пример #2
0
        public void NonBoolWithUnary(object operandFirst1, object operandFirst2, FilterOperator filterOp1, FilterOperator filterOp2, object expectedResult)
        {
            // Setup the First ContentfilterElement (the BitwiseOr or BitwiseAnd filter operation)
            LiteralOperand loperand1 = new LiteralOperand();
            LiteralOperand loperand2 = new LiteralOperand();
            loperand1.Value = new Variant(operandFirst1);
            if (filterOp1 == FilterOperator.Cast)
            {
                NodeId uintNoid = new NodeId(operandFirst2, 0);
                loperand2.Value = new Variant(uintNoid);
            }
            else
            {
                loperand2.Value = new Variant(operandFirst2);
            }
            

            ContentFilterElement filterElement1 = new ContentFilterElement();
            filterElement1.FilterOperator = filterOp1;
            filterElement1.SetOperands(new List<FilterOperand>() { loperand1, loperand2 });

            // Setup the Second ContentfilterElement
            ElementOperand elementOperand = new ElementOperand();
            elementOperand.Index = 1; // link to filterElement1

            ContentFilterElement filterElement2 = new ContentFilterElement();
            filterElement2.FilterOperator = filterOp2;
            filterElement2.SetOperands(new List<FilterOperand>() { elementOperand });

            Filter.WhereClause.Elements = new[] { filterElement2, filterElement1 };

            // apply filter.
            object result = Filter.WhereClause.Evaluate(FilterContext, TestFilterTarget);
            Assert.AreEqual(expectedResult, result);
        }
Пример #3
0
        public void InList(object operandFirst1, object operandFirst2, object operandFirst3, object operandFirst4, object expectedResult)
        {
            LiteralOperand loperand1 = new LiteralOperand();
            LiteralOperand loperand2 = new LiteralOperand();
            LiteralOperand loperand3 = new LiteralOperand();
            LiteralOperand loperand4 = new LiteralOperand();

            loperand1.Value = new Variant(operandFirst1);
            loperand2.Value = new Variant(operandFirst2);
            loperand3.Value = new Variant(operandFirst3);
            loperand4.Value = new Variant(operandFirst4);

            ContentFilterElement filterElement = new ContentFilterElement();

            filterElement.FilterOperator = FilterOperator.InList;
            filterElement.SetOperands(new List <LiteralOperand>()
            {
                loperand1, loperand2, loperand3, loperand4
            });
            Filter.WhereClause.Elements = new[] { filterElement };

            // apply filter.
            object result = Filter.WhereClause.Evaluate(FilterContext, TestFilterTarget);

            Assert.AreEqual(expectedResult, result);
        }
Пример #4
0
        public void UnaryFilterOperators(object operandFirst1, FilterOperator filterOp, object expectedResult)
        {
            LiteralOperand loperand1 = new LiteralOperand();

            loperand1.Value = new Variant(operandFirst1);

            ContentFilterElement filterElement = new ContentFilterElement();
            filterElement.FilterOperator = filterOp;
            filterElement.SetOperands(new List<LiteralOperand>() { loperand1 });
            Filter.WhereClause.Elements = new[] { filterElement };

            // apply filter.
            object result = Filter.WhereClause.Evaluate(FilterContext, TestFilterTarget);
            Assert.AreEqual(expectedResult, result);
        }