Example #1
0
        public void WarewolfParse_Eval_where_WithNoIndexAndMultipleColumns_ComplexIndexThatIsStar()
        {
            var assigns = new List <IAssignValue>
            {
                new AssignValue("[[rec().a]]", "25"),
                new AssignValue("[[rec().b]]", "33"),
                new AssignValue("[[rec().b]]", "26"),
                new AssignValue("[[rec().a]]", "27"),
                new AssignValue("[[a]]", "*"),
            };
            var testEnv = WarewolfTestData.CreateTestEnvEmpty("");


            var testEnv2 = PublicFunctions.EvalMultiAssign(assigns, 0, testEnv);

            var env = new ExecutionEnvironment();

            env.AssignWithFrame(new AssignValue("[[rec().a]]", "25"), 0);
            env.AssignWithFrame(new AssignValue("[[rec().a]]", "26"), 0);
            env.AssignWithFrame(new AssignValue("[[rec().a]]", "27"), 0);
            env.AssignWithFrame(new AssignValue("[[rec().a]]", "28"), 0);
            env.AssignWithFrame(new AssignValue("[[a]]", "*"), 0);
            var items = env.EvalWhere("[[rec([[a]]).a]]", a => PublicFunctions.AtomtoString(a) == "25", 0);

            Assert.AreEqual(items.ToArray()[0], 1);
        }
Example #2
0
        public void WarewolfParse_Eval_where_WithNoIndexAndMultipleColumns_Multipleresults()
        {
            var assigns = new List <IAssignValue>
            {
                new AssignValue("[[rec().a]]", "25"),
                new AssignValue("[[rec().b]]", "33"),
                new AssignValue("[[rec().b]]", "25"),
                new AssignValue("[[rec().a]]", "27"),
            };
            var testEnv = WarewolfTestData.CreateTestEnvEmpty("");


            var testEnv2 = PublicFunctions.EvalMultiAssign(assigns, 0, testEnv);

            var env = new ExecutionEnvironment();

            env.AssignWithFrame(new AssignValue("[[rec().a]]", "25"), 0);
            env.AssignWithFrame(new AssignValue("[[rec().a]]", "26"), 0);
            env.AssignWithFrame(new AssignValue("[[rec().a]]", "25"), 0);
            env.AssignWithFrame(new AssignValue("[[rec().a]]", "28"), 0);

            var items = env.EvalWhere("[[rec(*).a]]", a => PublicFunctions.AtomtoString(a) == "25", 0);

            IEnumerable <int> enumerable = items as int[] ?? items.ToArray();

            Assert.AreEqual(enumerable.ToArray()[0], 1);
            Assert.AreEqual(enumerable.ToArray()[1], 3);
        }
Example #3
0
        public void WarewolfParse_Eval_where_nonExistentRecset()
        {
            var assigns = new List <IAssignValue>
            {
                new AssignValue("[[rec().a]]", "25"),
                new AssignValue("[[rec().b]]", "33"),
                new AssignValue("[[rec().b]]", "26"),
                new AssignValue("[[rec().a]]", "27"),
            };
            var testEnv = WarewolfTestData.CreateTestEnvEmpty("");


            var testEnv2 = PublicFunctions.EvalMultiAssign(assigns, 0, testEnv);

            var env = new ExecutionEnvironment();

            env.AssignWithFrame(new AssignValue("[[rec().a]]", "1"), 0);
            env.AssignWithFrame(new AssignValue("[[rec().a]]", "26"), 0);
            env.AssignWithFrame(new AssignValue("[[rec().a]]", "27"), 0);
            env.AssignWithFrame(new AssignValue("[[rec().a]]", "28"), 0);

            var items = env.EvalWhere("[[bec().a]]", a => PublicFunctions.AtomtoString(a) == "25", 0);

            Assert.AreEqual(items.ToArray()[0], 1);
        }
        public void WarewolfParse_Eval_where_WithNoIndexAndMultipleColumns_MultipleEvalsErrorsRecordSetName()
        {
            var testEnv = WarewolfTestData.CreateTestEnvEmpty("");
            var assigns = new List <IAssignValue>
            {
                new AssignValue("[[rec().a]]", "25"),
                new AssignValue("[[rec().b]]", "33"),
                new AssignValue("[[rec().b]]", "26"),
                new AssignValue("[[rec().a]]", "27"),
            };
            ExecutionEnvironment env = new ExecutionEnvironment();

            // ReSharper disable UnusedVariable
            var testEnv2 = PublicFunctions.EvalMultiAssign(assigns, 0, testEnv);

            // ReSharper restore UnusedVariable

            env.AssignWithFrame(new AssignValue("[[rec().a]]", "25"), 0);
            env.AssignWithFrame(new AssignValue("[[rec().a]]", "26"), 0);
            env.AssignWithFrame(new AssignValue("[[rec().a]]", "27"), 0);
            env.AssignWithFrame(new AssignValue("[[rec().a]]", "28"), 0);

            // ReSharper restore UnusedVariable

            var items = env.EvalWhere("[[rec()]]", a => PublicFunctions.AtomtoString(a) == "25", 0);

            Assert.AreEqual(items.ToArray()[0], 1);
        }
Example #5
0
 public static string WarewolfAtomToString(DataASTMutable.WarewolfAtom a)
 {
     if (a == null)
     {
         return("");
     }
     return(PublicFunctions.AtomtoString(a));
 }
Example #6
0
        public void WarewolfParse_Eval_where_WithNoIndexAndMultipleColumns_MultipleEvalsErrorsOnComplex()
        {
            var testEnv = WarewolfTestData.CreateTestEnvEmpty("");

            var env = new ExecutionEnvironment();

            var items = env.EvalWhere("[[rec()]] b", a => PublicFunctions.AtomtoString(a) == "25", 0);
        }
Example #7
0
            static void AtomInputs(CommonFunctions.WarewolfEvalResult warewolfEvalResult, IDev2Definition dev2ColumnDefinition, IExecutionEnvironment env)
            {
                var recsetResult = warewolfEvalResult as CommonFunctions.WarewolfEvalResult.WarewolfAtomResult;

                if (dev2ColumnDefinition.IsRecordSet && recsetResult != null)
                {
                    var correctRecSet = "[[" + dev2ColumnDefinition.RecordSetName + "(*)." + dev2ColumnDefinition.Name + "]]";
                    env.AssignWithFrame(new AssignValue(correctRecSet, PublicFunctions.AtomtoString(recsetResult.Item)), 0);
                }
            }
Example #8
0
        public void WarewolfParse_Eval_where_recset()
        {
            WarewolfTestData.CreateTestEnvEmpty("");



            var env = new ExecutionEnvironment();

            var items = env.EvalWhere("x", a => PublicFunctions.AtomtoString(a) == "25", 0);
        }
        public void WarewolfParse_Eval_where_recset()
        {
            WarewolfTestData.CreateTestEnvEmpty("");


            // ReSharper restore UnusedVariable
            ExecutionEnvironment env = new ExecutionEnvironment();
            // ReSharper disable once UnusedVariable
            var items = env.EvalWhere("x", a => PublicFunctions.AtomtoString(a) == "25", 0);
        }
        public void WarewolfParse_Eval_where_WithNoIndexAndMultipleColumns_MultipleEvalsErrorsOnScalar()
        {
            var testEnv = WarewolfTestData.CreateTestEnvEmpty("");


            // ReSharper restore UnusedVariable
            ExecutionEnvironment env = new ExecutionEnvironment();


            var items = env.EvalWhere("[[a]]", a => PublicFunctions.AtomtoString(a) == "25", 0);
        }
Example #11
0
        static void AddScalarsToOutput(JProperty prop, IExecutionEnvironment environment, string objName, JObject outputObj, enDev2ColumnArgumentDirection requestIODirection)
        {
            var v      = prop.Value as JObject;
            var ioDire = v?.Properties().FirstOrDefault(property => property.Name == "@ColumnIODirection");

            if (ioDire != null)
            {
                var x = (enDev2ColumnArgumentDirection)Enum.Parse(typeof(enDev2ColumnArgumentDirection), ioDire.Value.ToString());
                if ((x == enDev2ColumnArgumentDirection.Both || x == requestIODirection) && (environment.Eval("[[" + objName + "]]", 0) is CommonFunctions.WarewolfEvalResult.WarewolfAtomResult warewolfEvalResult))
                {
                    var eval = PublicFunctions.AtomtoString(warewolfEvalResult.Item);
                    outputObj.Add(objName, eval);
                }
            }
        }