Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public void WarewolfParse_Eval_Assign_MultipleEvals_Star()
        {
            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]]", "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);

            var items = env.EvalAsListOfStrings("[[rec(*).a]]", 0);

            Assert.AreEqual(items.ToArray()[0], "28");
            Assert.AreEqual(items.ToArray()[1], "28");
        }
Exemplo n.º 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);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        public void WarewolfParse_Eval_Assign_MultipleEvals_Star_NonExistent()
        {
            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("");

            // ReSharper disable UnusedVariable
            var testEnv2 = PublicFunctions.EvalMultiAssign(assigns, 0, testEnv);
            // ReSharper restore UnusedVariable
            ExecutionEnvironment 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("[[rsec(*).a]]", "28"), 0);

            var items = env.EvalAsListOfStrings("[[rsec(*).a]]", 0);

            Assert.AreEqual(items.Count, 1);
            Assert.AreEqual(items[0], "28");
        }
        static DataStorage.WarewolfEnvironment EvalMultiAssign()
        {
            var assigns = new List <IAssignValue>
            {
                new AssignValue("[[rec(1).a]]", "27"),
                new AssignValue("[[rec(3).a]]", "33"),
                new AssignValue("[[rec(2).a]]", "25")
            };
            var envEmpty        = WarewolfTestData.CreateTestEnvEmpty("");
            var evalMultiAssign = PublicFunctions.EvalMultiAssign(assigns, 0, envEmpty);

            return(evalMultiAssign);
        }
Exemplo n.º 8
0
 public void MultiAssign(IEnumerable <IAssignValue> values)
 {
     try
     {
         var envTemp = PublicFunctions.EvalMultiAssign(values, _env);
         _env = envTemp;
     }
     catch (Exception err)
     {
         Errors.Add(err.Message);
         throw;
     }
 }
        static DataStorage.WarewolfEnvironment EvalMultiAssignTwoColumn()
        {
            var assigns = new List <IAssignValue>
            {
                new AssignValue("[[rec().a]]", "a11"),
                new AssignValue("[[rec().b]]", ""),
                new AssignValue("[[rec().c]]", "c22"),
                new AssignValue("[[rec().a]]", "ayy"),
                new AssignValue("[[rec().b]]", "b33"),
                new AssignValue("[[rec().c]]", "czz")
            };
            var envEmpty        = WarewolfTestData.CreateTestEnvEmpty("");
            var evalMultiAssign = PublicFunctions.EvalMultiAssign(assigns, 0, envEmpty);

            return(evalMultiAssign);
        }
Exemplo n.º 10
0
        private DataStorage.WarewolfEnvironment CreateTestEnvWithData()
        {
            IEnumerable <IAssignValue> assigns = new List <IAssignValue>
            {
                new AssignValue("[[rec().a]]", "2"),
                new AssignValue("[[rec().a]]", "4"),
                new AssignValue("[[rec().a]]", "Bob"),
                new AssignValue("[[a]]", "5"),
                new AssignValue("[[b]]", "2344"),
                new AssignValue("[[c]]", "a"),
                new AssignValue("[[d]]", "1")
            };
            var env = WarewolfTestData.CreateTestEnvEmpty("");

            var env2 = PublicFunctions.EvalMultiAssign(assigns, 0, env);

            return(env2);
        }
Exemplo n.º 11
0
        public void AppendObjectToArrayInAnObject()
        {
            var assigns = new List <IAssignValue>
            {
                new AssignValue("[[@obj.addr().a]]", "125"),
                new AssignValue("[[@obj.addr().b]]", "133"),
                new AssignValue("[[@obj.addr().c]]", "126"),

                new AssignValue("[[@obj.addr().a]]", "225"),
                new AssignValue("[[@obj.addr().b]]", "233"),
                new AssignValue("[[@obj.addr().c]]", "226"),
            };
            var testEnv = WarewolfTestData.CreateTestEnvEmpty("");

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

            // assert that a, b, and c belong to the same object in the addr array inside obj
            Assert.IsTrue(testEnv2.JsonObjects.ContainsKey("obj"));
            var obj = testEnv2.JsonObjects["obj"] as JObject;

            Assert.IsNotNull(obj, "not a JObject");
            var addrList = obj["addr"] as JArray;

            Assert.IsNotNull(addrList, "not a JArray");
            Assert.AreEqual(2, addrList.Count);
            var addr = addrList.First as JObject;

            Assert.IsNotNull(addr, "not a JObject");

            Assert.AreEqual(125, addr["a"].Value <int>());
            Assert.AreEqual(133, addr["b"].Value <int>());
            Assert.AreEqual(126, addr["c"].Value <int>());

            addr = addrList.Last as JObject;
            Assert.AreEqual(225, addr["a"].Value <int>());
            Assert.AreEqual(233, addr["b"].Value <int>());
            Assert.AreEqual(226, addr["c"].Value <int>());
        }
Exemplo n.º 12
0
        public void WarewolfIterator_SetupForWarewolfRecordSetResult_Should()
        {
            var listResult   = CommonFunctions.WarewolfEvalResult.NewWarewolfAtomResult(DataStorage.WarewolfAtom.Nothing);
            var atomIterator = new WarewolfIterator(listResult);

            Assert.IsNotNull(atomIterator);
            var privateObj = new PrivateObject(atomIterator);
            var assigns    = new List <IAssignValue>
            {
                new AssignValue("[[rec(25).a]]", "25"),
                new AssignValue("[[rec(27).b]]", "33"),
                new AssignValue("[[rec(29).b]]", "26")
            };
            var testEnv  = WarewolfTestData.CreateTestEnvEmpty("");
            var testEnv3 = PublicFunctions.EvalMultiAssign(assigns, 0, testEnv);
            var res      = PublicFunctions.EvalEnvExpression("[[rec(27)]]", 0, false, testEnv3);

            Assert.IsTrue(res.IsWarewolfRecordSetResult);
            object[] arg = { res };
            privateObj.Invoke("SetupForWarewolfRecordSetResult", arg);
            var scalarRes = privateObj.GetField("_scalarResult") as CommonFunctions.WarewolfEvalResult.WarewolfAtomResult;

            Assert.IsNotNull(scalarRes);
        }
Exemplo n.º 13
0
        public void MultiAssign(IEnumerable <IAssignValue> values, int update)
        {
            var envTemp = PublicFunctions.EvalMultiAssign(values, update, _env);

            _env = envTemp;
        }