Пример #1
0
 /// <summary>
 /// Folds expression from given expressions.
 /// </summary>
 /// <param name="expressions">The expressions.</param>
 /// <returns>The expression.</returns>
 public static IExpression FoldExpression(params IExpression[] expressions)
 {
     return(TestExprFactory.FoldExpression(expressions.ToList()));
 }
Пример #2
0
 /// <summary>
 /// Gets the expression by testing data type.
 /// </summary>
 /// <param name="type">The testing data type.</param>
 /// <returns>The expression.</returns>
 public static IExpression GetExpression(TestExprType type)
 {
     return(TestExprFactory.GetExpression(true, type));
 }
Пример #3
0
 /// <summary>
 /// Gets the expression by testing data types.
 /// </summary>
 /// <param name="types">The testing data types.</param>
 /// <returns>The expression.</returns>
 public static IExpression GetExpression(params TestExprType[] types)
 {
     return(TestExprFactory.GetExpression(false, types));
 }
Пример #4
0
        /// <summary>
        /// Gets the expression by testing data types.
        /// </summary>
        /// <param name="noChildren">Specifies if returning expression has to have descendant expressions.</param>
        /// <param name="types">The testing data types.</param>
        /// <returns>The expression.</returns>
        private static IExpression GetExpression(bool noChildren, params TestExprType[] types)
        {
            if (noChildren && types.Length != 1)
            {
                throw new Exception();
            }

            IExpression expr = ModelResolvers.ExprResolver();

            for (int i = 0; i < types.Length; i++)
            {
                IExpression operand = ModelResolvers.ExprResolver();
                switch (types[i])
                {
                case TestExprType.IntsDataset:
                    operand =
                        TestExprFactory.GetDatasetExpr(
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Identifier, BasicDataType.Integer),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.Integer),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.Integer));
                    break;

                case TestExprType.NumbersDataset:
                    operand =
                        TestExprFactory.GetDatasetExpr(
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Identifier, BasicDataType.Integer),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.Number),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.Number));
                    break;

                case TestExprType.StringsDataset:
                    operand =
                        TestExprFactory.GetDatasetExpr(
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Identifier, BasicDataType.Integer),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.String),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.String));
                    break;

                case TestExprType.BoolsDataset:
                    operand =
                        TestExprFactory.GetDatasetExpr(
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Identifier, BasicDataType.Integer),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.Boolean),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.Boolean));
                    break;

                case TestExprType.TimesDataset:
                    operand =
                        TestExprFactory.GetDatasetExpr(
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Identifier, BasicDataType.Integer),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.Time),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.Time));
                    break;

                case TestExprType.DatesDataset:
                    operand =
                        TestExprFactory.GetDatasetExpr(
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Identifier, BasicDataType.Integer),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.Date),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.Date));
                    break;

                case TestExprType.TimePeriodsDataset:
                    operand =
                        TestExprFactory.GetDatasetExpr(
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Identifier, BasicDataType.Integer),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.TimePeriod),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.TimePeriod));
                    break;

                case TestExprType.DurationsDataset:
                    operand =
                        TestExprFactory.GetDatasetExpr(
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Identifier, BasicDataType.Integer),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.Duration),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.Duration));
                    break;

                case TestExprType.NonesDataset:
                    operand =
                        TestExprFactory.GetDatasetExpr(
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Identifier, BasicDataType.Integer),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.None),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.None));
                    break;

                case TestExprType.MixedIntNumDataset:
                    operand =
                        TestExprFactory.GetDatasetExpr(
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Identifier, BasicDataType.Integer),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.Integer),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.Number));
                    break;

                case TestExprType.MixedNumStrDataset:
                    operand =
                        TestExprFactory.GetDatasetExpr(
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Identifier, BasicDataType.Integer),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.Number),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.String));
                    break;

                case TestExprType.MixedNoneIntDataset:
                    operand =
                        TestExprFactory.GetDatasetExpr(
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Identifier, BasicDataType.Integer),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.None),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.Integer));
                    break;

                case TestExprType.MixedNoneNumDataset:
                    operand =
                        TestExprFactory.GetDatasetExpr(
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Identifier, BasicDataType.Integer),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.None),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.Number));
                    break;

                case TestExprType.MixedNoneStrDataset:
                    operand =
                        TestExprFactory.GetDatasetExpr(
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Identifier, BasicDataType.Integer),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.None),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.String));
                    break;

                case TestExprType.MixedNoneBoolDataset:
                    operand =
                        TestExprFactory.GetDatasetExpr(
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Identifier, BasicDataType.Integer),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.None),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.Boolean));
                    break;

                case TestExprType.MixedNoneTimeDataset:
                    operand =
                        TestExprFactory.GetDatasetExpr(
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Identifier, BasicDataType.Integer),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.None),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.Time));
                    break;

                case TestExprType.MixedNoneDateDataset:
                    operand =
                        TestExprFactory.GetDatasetExpr(
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Identifier, BasicDataType.Integer),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.None),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.Date));
                    break;

                case TestExprType.MixedNoneTimePerDataset:
                    operand =
                        TestExprFactory.GetDatasetExpr(
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Identifier, BasicDataType.Integer),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.None),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.TimePeriod));
                    break;

                case TestExprType.MixedNoneDurDataset:
                    operand =
                        TestExprFactory.GetDatasetExpr(
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Identifier, BasicDataType.Integer),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.None),
                            new KeyValuePair <ComponentType, BasicDataType>(ComponentType.Measure, BasicDataType.Duration));
                    break;

                default:
                    operand.Structure = ModelResolvers.DsResolver("const", ComponentType.Measure, (BasicDataType)types[i]);
                    break;
                }

                if (!noChildren)
                {
                    expr.AddOperand($"ds_{i + 1}", operand);
                }
                else
                {
                    expr = operand;
                }
            }

            return(expr);
        }