Esempio n. 1
0
        public void GetOutputStructure_CalcComponentExpr_DataStructure(string keyword)
        {
            IExpression calcExpr = ModelResolvers.ExprResolver();
            IExpression compExpr = ModelResolvers.ExprResolver();

            compExpr.ExpressionText             = "component";
            compExpr.OperatorDefinition         = ModelResolvers.OperatorResolver("comp");
            calcExpr.OperatorDefinition         = ModelResolvers.OperatorResolver("calcExpr");
            calcExpr.OperatorDefinition.Keyword = keyword;
            calcExpr.AddOperand("ds_1", compExpr);

            ComponentType compType;

            switch (keyword)
            {
            case "identifier": compType = ComponentType.Identifier; break;

            case "measure": compType = ComponentType.Measure; break;

            case "attribute": compType = ComponentType.NonViralAttribute; break;

            case "viral attribute": compType = ComponentType.ViralAttribute; break;

            default: throw new ArgumentOutOfRangeException("keyword");
            }

            IDataStructure dataStructure = compExpr.OperatorDefinition.GetOutputStructure(compExpr);

            Assert.True(dataStructure.IsSingleComponent);
            Assert.Equal(compType, dataStructure.Components[0].ComponentType);
        }
        public void GetOutputStructure_WrongArgExpr_ThrowsException()
        {
            TestExprType[][] correctCombs = new TestExprType[][] {
                new TestExprType[] { TestExprType.Integer },
                new TestExprType[] { TestExprType.Number },
                new TestExprType[] { TestExprType.None },
                new TestExprType[] { TestExprType.IntsDataset },
                new TestExprType[] { TestExprType.NumbersDataset },
                new TestExprType[] { TestExprType.MixedIntNumDataset },
                new TestExprType[] { TestExprType.NonesDataset },
                new TestExprType[] { TestExprType.MixedNoneIntDataset },
                new TestExprType[] { TestExprType.MixedNoneNumDataset }
            };

            TestExprType[][] combinations = Enum.GetValues(typeof(TestExprType)).Cast <TestExprType>().GetCombinations(1);
            TestExprType[][] wrongCombs   = combinations.Without(correctCombs);

            foreach (string opSymbol in this._operators)
            {
                foreach (TestExprType[] wrongComb in wrongCombs)
                {
                    IExpression unaryArithmeticExpr = TestExprFactory.GetExpression(wrongComb);
                    unaryArithmeticExpr.OperatorDefinition = ModelResolvers.OperatorResolver(opSymbol);

                    // Debug condition example: wrongComb[0] == TestExprType.Integer
                    Assert.ThrowsAny <VtlOperatorError>(() => { unaryArithmeticExpr.OperatorDefinition.GetOutputStructure(unaryArithmeticExpr); });
                }
            }
        }
        public void GetOutputStructure_CorrectSingleMeasureExpr_DataStructure(params TestExprType[] types)
        {
            IExpression nvlExpr = TestExprFactory.GetExpression(types[0], types[1]);

            nvlExpr.OperatorDefinition = ModelResolvers.OperatorResolver("nvl");

            if (nvlExpr.Operands["ds_1"].Structure.Measures.Count > 1)
            {
                nvlExpr.Operands["ds_1"].Structure.Measures.RemoveAt(1);
            }
            if (nvlExpr.Operands["ds_2"].Structure.Measures.Count > 1)
            {
                nvlExpr.Operands["ds_2"].Structure.Measures.RemoveAt(1);
            }

            IExpression expected = TestExprFactory.GetExpression(types[2]);

            if (expected.Structure.Measures.Count > 1)
            {
                expected.Structure.Measures.RemoveAt(1);
            }

            IDataStructure dataStructure = nvlExpr.OperatorDefinition.GetOutputStructure(nvlExpr);

            Assert.True(expected.Structure.EqualsObj(dataStructure));
        }
Esempio n. 4
0
        public void GetOutputStructure_WrongArgsExpr_ThrowsException()
        {
            TestExprType[][] correctCombs = new TestExprType[][] {
                new TestExprType[] { TestExprType.String, TestExprType.String },
                new TestExprType[] { TestExprType.String, TestExprType.None },
                new TestExprType[] { TestExprType.None, TestExprType.String },
                new TestExprType[] { TestExprType.None, TestExprType.None },
                new TestExprType[] { TestExprType.StringsDataset, TestExprType.String },
                new TestExprType[] { TestExprType.StringsDataset, TestExprType.None },
                new TestExprType[] { TestExprType.NonesDataset, TestExprType.String },
                new TestExprType[] { TestExprType.NonesDataset, TestExprType.None }
            };

            TestExprType[][] combinations = Enum.GetValues(typeof(TestExprType)).Cast <TestExprType>().GetCombinations(2);
            TestExprType[][] wrongCombs   = combinations.Without(correctCombs);

            foreach (TestExprType[] wrongComb in wrongCombs.Where(wrongComb => (int)wrongComb[0] < 18 && (int)wrongComb[1] < 18)) // No mixed datasets
            {
                IExpression stringExpr = TestExprFactory.GetExpression(wrongComb);
                stringExpr.OperatorDefinition = ModelResolvers.OperatorResolver("match_characters");

                if (!stringExpr.Operands["ds_1"].IsScalar)
                {
                    stringExpr.Operands["ds_1"].Structure.Measures.RemoveAt(1);
                }
                if (!stringExpr.Operands["ds_2"].IsScalar)
                {
                    stringExpr.Operands["ds_2"].Structure.Measures.RemoveAt(1);
                }

                // Debug condition example: wrongComb[0] == TestExprType.Integer && wrongComb[1] == TestExprType.Integer
                Assert.ThrowsAny <VtlOperatorError>(() => { stringExpr.OperatorDefinition.GetOutputStructure(stringExpr); });
            }
        }
        public void GetOutputStructure_MultiMeasuresDatasetExpr_ThrowsException()
        {
            TestExprType[][] scalars = new TestExprType[][] {
                new TestExprType[] { TestExprType.Integer },
                new TestExprType[] { TestExprType.Number },
                new TestExprType[] { TestExprType.String },
                new TestExprType[] { TestExprType.Boolean },
                new TestExprType[] { TestExprType.Time },
                new TestExprType[] { TestExprType.Date },
                new TestExprType[] { TestExprType.TimePeriod },
                new TestExprType[] { TestExprType.Duration },
                new TestExprType[] { TestExprType.None }
            };

            TestExprType[][] types    = Enum.GetValues(typeof(TestExprType)).Cast <TestExprType>().GetCombinations(1);
            TestExprType[][] datasets = types.Without(scalars);

            foreach (TestExprType[] dataset in datasets)
            {
                IExpression isNullExpr = TestExprFactory.GetExpression(dataset);
                isNullExpr.OperatorDefinition = ModelResolvers.OperatorResolver("isnull");

                // Debug condition example: dataset[0] == TestExprType.IntsDataset
                Assert.ThrowsAny <VtlOperatorError>(() => { isNullExpr.OperatorDefinition.GetOutputStructure(isNullExpr); });
            }
        }
Esempio n. 6
0
        public void GetOutputStructure_WrongArgExpr1Arg_ThrowsException(string opSymbol)
        {
            TestExprType[][] correctCombs = new TestExprType[][] {
                new TestExprType[] { TestExprType.String },
                new TestExprType[] { TestExprType.None },
                new TestExprType[] { TestExprType.StringsDataset },
                new TestExprType[] { TestExprType.NonesDataset },
                new TestExprType[] { TestExprType.MixedNoneStrDataset }
            };

            TestExprType[][] combinations = Enum.GetValues(typeof(TestExprType)).Cast <TestExprType>().GetCombinations(1);
            TestExprType[][] wrongCombs   = combinations.Without(correctCombs.ToArray());

            foreach (TestExprType[] wrongComb in wrongCombs.Where(wrongComb => (int)wrongComb[0] < 18)) // No mixed datasets
            {
                IExpression stringExpr = TestExprFactory.GetExpression(new TestExprType[] { wrongComb[0] });
                stringExpr.OperatorDefinition = ModelResolvers.OperatorResolver(opSymbol);
                if (opSymbol.In("length", "instr") && stringExpr.Operands["ds_1"].Structure.Measures.Count > 1)
                {
                    stringExpr.Operands["ds_1"].Structure.Measures.RemoveAt(1);
                }

                // Debug condition example: wrongComb[0] == TestExprType.Integer
                Assert.ThrowsAny <VtlOperatorError>(() => { stringExpr.OperatorDefinition.GetOutputStructure(stringExpr); });
            }
        }
        public void GetOutputStructure_Correct1Superset1SubsetExpr_SupersetModified(params TestExprType[] types)
        {
            foreach (string opSymbol in this._operators)
            {
                IExpression arithmeticExpr = TestExprFactory.GetExpression(types);
                arithmeticExpr.OperatorDefinition = ModelResolvers.OperatorResolver(opSymbol);

                arithmeticExpr.Operands["ds_1"].Structure.Identifiers.Add(new StructureComponent(BasicDataType.Integer, "Id2"));

                IDataStructure expectedStructure = arithmeticExpr.Operands[$"ds_1"].Structure.GetCopy();
                for (int i = 0; i < expectedStructure.Measures.Count; i++)
                {
                    BasicDataType dataType = arithmeticExpr.Operands[$"ds_2"].Structure.Measures[i].ValueDomain.DataType;
                    if (dataType == BasicDataType.Number)
                    {
                        expectedStructure.Measures[i].ValueDomain = new ValueDomain(dataType);
                    }
                    if (expectedStructure.Measures[i].ValueDomain.DataType == BasicDataType.None)
                    {
                        expectedStructure.Measures[i].ValueDomain = new ValueDomain(BasicDataType.Integer);
                    }
                }

                IDataStructure dataStructure = arithmeticExpr.OperatorDefinition.GetOutputStructure(arithmeticExpr);

                Assert.True(expectedStructure.EqualsObj(dataStructure));
            }
        }
Esempio n. 8
0
        public void GetOutputStructure_CorrectDatasetCollectionExpr_BoolScalarStructure()
        {
            foreach (string opSymbol in this._operators)
            {
                IExpression collectionExpr = ModelResolvers.ExprResolver();
                collectionExpr.Structure          = ModelResolvers.DsResolver();
                collectionExpr.OperatorDefinition = ModelResolvers.OperatorResolver("collection");
                collectionExpr.Structure.Measures.Add(new StructureComponent(BasicDataType.Integer));
                collectionExpr.Structure.Measures.Add(new StructureComponent(BasicDataType.Number));
                collectionExpr.Structure.Measures.Add(new StructureComponent(BasicDataType.None));

                IExpression inExpr = ModelResolvers.ExprResolver();
                inExpr.AddOperand("ds_1", TestExprFactory.GetExpression(TestExprType.NumbersDataset));
                inExpr.AddOperand("ds_2", collectionExpr);

                inExpr.Operands["ds_1"].Structure.Measures.RemoveAt(1);

                inExpr.OperatorDefinition = ModelResolvers.OperatorResolver(opSymbol);

                IExpression expected = TestExprFactory.GetExpression(TestExprType.BoolsDataset);
                expected.Structure.Measures.RemoveAt(1);

                IDataStructure dataStructure = inExpr.OperatorDefinition.GetOutputStructure(inExpr);

                Assert.True(expected.Structure.EqualsObj(dataStructure));
            }
        }
Esempio n. 9
0
        public void GetOutputStructure_CorrectComponentTwoDatasetsJoinExpr_DurationScalarStructure()
        {
            foreach (string name in DatasetClauseOperator.ClauseNames.Where(name => !name.In("Pivot", "Unpivot", "Subspace")))
            {
                IExpression joinExpr            = ModelResolvers.JoinExprResolver(TestExprFactory.GetExpression("join", ExpressionFactoryNameTarget.OperatorSymbol));
                IExpression ds1Expr             = TestExprFactory.GetExpression("get", ExpressionFactoryNameTarget.OperatorSymbol);
                IExpression ds2Expr             = TestExprFactory.GetExpression("get", ExpressionFactoryNameTarget.OperatorSymbol);
                IExpression clauseExpr          = TestExprFactory.GetExpression(name, ExpressionFactoryNameTarget.ResultName);
                IExpression periodIndicatorExpr = TestExprFactory.GetExpression("period_indicator", ExpressionFactoryNameTarget.OperatorSymbol);
                IExpression paramExpr           = TestExprFactory.GetExpression(TestExprType.TimePeriod);
                paramExpr.OperatorDefinition = ModelResolvers.OperatorResolver("#");

                joinExpr.AddOperand("ds", ModelResolvers.ExprResolver());
                joinExpr.Operands["ds"].AddOperand("ds_1", ds1Expr);
                joinExpr.Operands["ds"].AddOperand("ds_2", ds2Expr);
                joinExpr.AddOperand(name, clauseExpr);
                clauseExpr.AddOperand("ds_1", periodIndicatorExpr);
                periodIndicatorExpr.AddOperand("ds_1", paramExpr);

                ds1Expr.Structure = ModelResolvers.DsResolver();
                ds1Expr.Structure.Identifiers.Add(new StructureComponent(BasicDataType.Integer, "Id1"));
                ds1Expr.Structure.Identifiers.Add(new StructureComponent(BasicDataType.TimePeriod, "Id2"));
                ds1Expr.Structure.Measures.Add(new StructureComponent(BasicDataType.String, "Me1"));

                IDataStructure expectedStructure = ModelResolvers.DsResolver("duration_var", ComponentType.Measure, BasicDataType.Duration);

                IDataStructure dataStructure = periodIndicatorExpr.OperatorDefinition.GetOutputStructure(periodIndicatorExpr);

                Assert.True(expectedStructure.EqualsObj(dataStructure));
            }
        }
Esempio n. 10
0
        public void GetOutputStructure_WrongComponentTwoDatasetsJoinExpr_DurationScalarStructure(bool isMemership, TestExprType type)
        {
            foreach (string name in DatasetClauseOperator.ClauseNames.Where(name => !name.In("Pivot", "Unpivot", "Subspace")))
            {
                IExpression joinExpr            = ModelResolvers.JoinExprResolver(TestExprFactory.GetExpression("join", ExpressionFactoryNameTarget.OperatorSymbol));
                IExpression ds1Expr             = TestExprFactory.GetExpression("get", ExpressionFactoryNameTarget.OperatorSymbol);
                IExpression ds2Expr             = TestExprFactory.GetExpression("get", ExpressionFactoryNameTarget.OperatorSymbol);
                IExpression clauseExpr          = TestExprFactory.GetExpression(name, ExpressionFactoryNameTarget.ResultName);
                IExpression periodIndicatorExpr = TestExprFactory.GetExpression("period_indicator", ExpressionFactoryNameTarget.OperatorSymbol);
                IExpression paramExpr           = TestExprFactory.GetExpression(type);
                if (isMemership)
                {
                    paramExpr.OperatorDefinition = ModelResolvers.OperatorResolver("#");
                }

                joinExpr.AddOperand("ds", ModelResolvers.ExprResolver());
                joinExpr.Operands["ds"].AddOperand("ds_1", ds1Expr);
                joinExpr.Operands["ds"].AddOperand("ds_2", ds2Expr);
                joinExpr.AddOperand(name, clauseExpr);
                clauseExpr.AddOperand("ds_1", periodIndicatorExpr);
                periodIndicatorExpr.AddOperand("ds_1", paramExpr);

                ds1Expr.Structure = ModelResolvers.DsResolver();
                ds1Expr.Structure.Identifiers.Add(new StructureComponent(BasicDataType.Integer, "Id1"));
                ds1Expr.Structure.Identifiers.Add(new StructureComponent((BasicDataType)type, "Id2"));
                ds1Expr.Structure.Measures.Add(new StructureComponent(BasicDataType.String, "Me1"));
                ds2Expr.Structure = ds1Expr.Structure.GetCopy();

                Assert.ThrowsAny <VtlOperatorError>(() => { periodIndicatorExpr.OperatorDefinition.GetOutputStructure(periodIndicatorExpr); });
            }
        }
Esempio n. 11
0
        public void GetOutputStructure_WrongArgExpr_ThrowsException()
        {
            TestExprType[][] correctCombs = new TestExprType[][] {
                new TestExprType[] { TestExprType.Boolean },
                new TestExprType[] { TestExprType.None },
                new TestExprType[] { TestExprType.BoolsDataset },
                new TestExprType[] { TestExprType.NonesDataset },
            };

            TestExprType[][] combinations = Enum.GetValues(typeof(TestExprType)).Cast <TestExprType>().GetCombinations(1);
            TestExprType[][] wrongCombs   = combinations.Without(correctCombs);

            foreach (TestExprType[] wrongComb in wrongCombs.Where(wrongComb => (int)wrongComb[0] < 18)) // No mixed datasets
            {
                IExpression notExpr = TestExprFactory.GetExpression(wrongComb);
                notExpr.OperatorDefinition = ModelResolvers.OperatorResolver("not");
                if (notExpr.Operands["ds_1"].Structure.Measures.Count > 1)
                {
                    notExpr.Operands["ds_1"].Structure.Measures.RemoveAt(1);
                }

                // Debug condition example: wrongComb[0] == TestExprType.Integer
                Assert.ThrowsAny <VtlOperatorError>(() => { notExpr.OperatorDefinition.GetOutputStructure(notExpr); });
            }
        }
Esempio n. 12
0
        public void OperatorDefinition_Set_OperatorSymbolSet(string opSymbol)
        {
            Expression expr = new Expression();

            expr.OperatorDefinition = ModelResolvers.OperatorResolver(opSymbol);

            Assert.Equal(opSymbol, expr.OperatorSymbol);
        }
Esempio n. 13
0
        public void GetOutputStructure_MultiMeasuresDatasetNScalarsExpr_ThrowsException(string opSymbol, params TestExprType[] types)
        {
            IExpression stringExpr = TestExprFactory.GetExpression(types);

            stringExpr.OperatorDefinition = ModelResolvers.OperatorResolver(opSymbol);

            Assert.ThrowsAny <VtlOperatorError>(() => { stringExpr.OperatorDefinition.GetOutputStructure(stringExpr); });
        }
Esempio n. 14
0
        public void GetOutputStructure_MultiMeasuresDatasetExpr_ThrowsException(TestExprType type)
        {
            IExpression notExpr = TestExprFactory.GetExpression(new TestExprType[] { type });

            notExpr.OperatorDefinition = ModelResolvers.OperatorResolver("not");

            Assert.ThrowsAny <VtlOperatorError>(() => { notExpr.OperatorDefinition.GetOutputStructure(notExpr); });
        }
Esempio n. 15
0
        public void GetOutputStructure_1MultiMeasuresDataset2CorrectScalarsArgsExpr_ThrowsException(params TestExprType[] types)
        {
            IExpression betweenExpr = TestExprFactory.GetExpression(types);

            betweenExpr.OperatorDefinition = ModelResolvers.OperatorResolver("between");

            Assert.ThrowsAny <VtlOperatorError>(() => { betweenExpr.OperatorDefinition.GetOutputStructure(betweenExpr); });
        }
Esempio n. 16
0
        public void GetOutputStructure_ScalarDatasetExpr_StringsDatasetStructure(string opSymbol, params TestExprType[] types)
        {
            IExpression stringExpr = TestExprFactory.GetExpression(types);

            stringExpr.OperatorDefinition = ModelResolvers.OperatorResolver(opSymbol);

            IDataStructure dataStructure = stringExpr.OperatorDefinition.GetOutputStructure(stringExpr);

            Assert.True(TestExprFactory.GetExpression(TestExprType.StringsDataset).Structure.EqualsObj(dataStructure));
        }
Esempio n. 17
0
        public void GetOutputStructure_CorrectScalarsExpr_BoolScalarStructure(params TestExprType[] types)
        {
            IExpression stringExpr = TestExprFactory.GetExpression(types);

            stringExpr.OperatorDefinition = ModelResolvers.OperatorResolver("match_characters");

            IDataStructure dataStructure = stringExpr.OperatorDefinition.GetOutputStructure(stringExpr);

            Assert.True(TestExprFactory.GetExpression(TestExprType.Boolean).Structure.EqualsObj(dataStructure));
        }
Esempio n. 18
0
        public void GetOutputStructure_WrongExpr_ThrowsException(string exprText)
        {
            IExpression constExpr = ModelResolvers.ExprResolver();

            constExpr.ExpressionText = exprText;

            constExpr.OperatorDefinition = ModelResolvers.OperatorResolver("const");

            Assert.ThrowsAny <VtlOperatorError>(() => { constExpr.OperatorDefinition.GetOutputStructure(constExpr); });
        }
Esempio n. 19
0
        public void GetOutputStructure_CorrectScalarExpr_BoolScalarStructure(TestExprType type)
        {
            IExpression notExpr = TestExprFactory.GetExpression(new TestExprType[] { type });

            notExpr.OperatorDefinition = ModelResolvers.OperatorResolver("not");

            IDataStructure dataStructure = notExpr.OperatorDefinition.GetOutputStructure(notExpr);

            Assert.True(TestExprFactory.GetExpression(TestExprType.Boolean).Structure.EqualsObj(dataStructure));
        }
Esempio n. 20
0
        public void GetOutputStructure_Correct3ScalarsArgsExpr_BoolScalarStructure(params TestExprType[] types)
        {
            IExpression betweenExpr = TestExprFactory.GetExpression(types);

            betweenExpr.OperatorDefinition = ModelResolvers.OperatorResolver("between");

            IDataStructure dataStructure = betweenExpr.OperatorDefinition.GetOutputStructure(betweenExpr);

            Assert.Equal(BasicDataType.Boolean, dataStructure.Components.First().ValueDomain.DataType);
        }
Esempio n. 21
0
        public void GetOutputStructure_CorrectScalarsExpr_NumberScalarStructure(string opSymbol, params TestExprType[] types)
        {
            IExpression numericExpr = TestExprFactory.GetExpression(types);

            numericExpr.OperatorDefinition = ModelResolvers.OperatorResolver(opSymbol);

            IDataStructure dataStructure = numericExpr.OperatorDefinition.GetOutputStructure(numericExpr);

            Assert.True(TestExprFactory.GetExpression(TestExprType.Number).Structure.EqualsObj(dataStructure));
        }
        public void GetOutputStructure_1MultiMeasuresDataset1CorrectScalarArgsExpr_ThrowsException(params TestExprType[] types)
        {
            foreach (string opSymbol in this._operators)
            {
                IExpression equalityExpr = TestExprFactory.GetExpression(types);
                equalityExpr.OperatorDefinition = ModelResolvers.OperatorResolver(opSymbol);

                Assert.ThrowsAny <VtlOperatorError>(() => { equalityExpr.OperatorDefinition.GetOutputStructure(equalityExpr); });
            }
        }
        public void GetOutputStructure_WrongOperatorKeyword_ThrowsException()
        {
            foreach (string opSymbol in this._operators)
            {
                IExpression compCreateExpr = TestExprFactory.GetExpression(TestExprType.Integer, TestExprType.Integer);
                compCreateExpr.OperatorDefinition         = ModelResolvers.OperatorResolver(opSymbol);
                compCreateExpr.OperatorDefinition.Keyword = "wrong keyword";

                Assert.ThrowsAny <VtlOperatorError>(() => { compCreateExpr.OperatorDefinition.GetOutputStructure(compCreateExpr); });
            }
        }
Esempio n. 24
0
        public void GetOutputStructure_WrongScalarExpr_ThrowsException(TestExprType type)
        {
            IExpression periodIndicatorExpr = TestExprFactory.GetExpression("period_indicator", ExpressionFactoryNameTarget.OperatorSymbol);
            IExpression scalarExpr          = TestExprFactory.GetExpression(type);

            scalarExpr.OperatorDefinition = ModelResolvers.OperatorResolver("const");

            periodIndicatorExpr.AddOperand("ds_1", scalarExpr);

            Assert.ThrowsAny <VtlOperatorError>(() => { periodIndicatorExpr.OperatorDefinition.GetOutputStructure(periodIndicatorExpr); });
        }
        public void GetOutputStructure_WrongExpr_ThrowsException()
        {
            IExpression membershipExpr = TestExprFactory.GetExpression(TestExprType.IntsDataset, TestExprType.Integer);

            membershipExpr.Operands["ds_2"].ExpressionText = "Component";
            membershipExpr.Operands["ds_2"].Structure.Components[0].ComponentName = "Component";

            membershipExpr.OperatorDefinition         = ModelResolvers.OperatorResolver("#");
            membershipExpr.OperatorDefinition.Keyword = "Standard";

            Assert.ThrowsAny <VtlOperatorError>(() => { membershipExpr.OperatorDefinition.GetOutputStructure(membershipExpr); });
        }
        public void GetOutputStructure_2NotMatchDatasetsExpr_ThrowsException(params TestExprType[] types)
        {
            foreach (string opSymbol in this._operators)
            {
                IExpression arithmeticExpr = TestExprFactory.GetExpression(types);
                arithmeticExpr.OperatorDefinition = ModelResolvers.OperatorResolver(opSymbol);

                arithmeticExpr.Operands["ds_1"].Structure.Measures.Add(new StructureComponent(BasicDataType.Integer, "Me3"));

                Assert.ThrowsAny <VtlOperatorError>(() => { arithmeticExpr.OperatorDefinition.GetOutputStructure(arithmeticExpr); });
            }
        }
        public void GetOutputStructure_Correct2ScalarsArgsExpr_BoolScalarStructure(params TestExprType[] types)
        {
            foreach (string opSymbol in this._operators)
            {
                IExpression equalityExpr = TestExprFactory.GetExpression(types);
                equalityExpr.OperatorDefinition = ModelResolvers.OperatorResolver(opSymbol);

                IDataStructure dataStructure = equalityExpr.OperatorDefinition.GetOutputStructure(equalityExpr);

                Assert.True(TestExprFactory.GetExpression(TestExprType.Boolean).Structure.EqualsObj(dataStructure));
            }
        }
Esempio n. 28
0
        public void GetOutputStructure_WrongComponentType(ComponentType wrongType)
        {
            IExpression expr = ModelResolvers.ExprResolver();

            expr.OperatorDefinition = ModelResolvers.OperatorResolver("sub");

            IExpression operand = TestExprFactory.GetDatasetExpr(new KeyValuePair <ComponentType, BasicDataType>(wrongType, BasicDataType.Integer));

            expr.AddOperand("ds_1", operand);

            Assert.ThrowsAny <Exception>(() => { expr.OperatorDefinition.GetOutputStructure(expr); });
        }
Esempio n. 29
0
        public void GetOutputStructure_Correct2ScalarsExpr_BoolScalarStructre(params TestExprType[] types)
        {
            foreach (string opSymbol in this._operators)
            {
                IExpression boolExpr = TestExprFactory.GetExpression(types[0], types[1]);
                boolExpr.OperatorDefinition = ModelResolvers.OperatorResolver(opSymbol);

                IDataStructure dataStructure = boolExpr.OperatorDefinition.GetOutputStructure(boolExpr);

                Assert.Equal(BasicDataType.Boolean, dataStructure.Components.First().ValueDomain.DataType);
            }
        }
Esempio n. 30
0
        public void GetOutputStructure_CorrectExpr_CorrectScalarStructure(TestExprType expectedType, string exprText)
        {
            IExpression constExpr = ModelResolvers.ExprResolver();

            constExpr.ExpressionText = exprText;

            constExpr.OperatorDefinition = ModelResolvers.OperatorResolver("const");

            IDataStructure dataStructure = constExpr.OperatorDefinition.GetOutputStructure(constExpr);

            Assert.True(TestExprFactory.GetExpression(expectedType).Structure.EqualsObj(dataStructure));
        }