Esempio n. 1
0
        public void TestNestedList()
        {
            CorePackage.Entity.Type.ListType intlist     = new CorePackage.Entity.Type.ListType(CorePackage.Entity.Type.Scalar.Integer);
            CorePackage.Entity.Type.ListType intlistlist = new CorePackage.Entity.Type.ListType(intlist);
            CorePackage.Execution.Append     instruction = new CorePackage.Execution.Append(intlist);
            List <List <int> > val = new List <List <int> >();

            instruction.SetInputValue("array", val);
            instruction.SetInputValue("element", new List <int>());

            Assert.IsTrue(instruction.GetInputValue("array").Count == 0);
            Assert.IsTrue(instruction.GetInputValue("element").Count == 0);

            instruction.Execute();

            Assert.IsTrue(val.Count == 1);

            CorePackage.Execution.Append           intlistappend = new CorePackage.Execution.Append(CorePackage.Entity.Type.Scalar.Integer);
            CorePackage.Execution.Operators.Access access        = new CorePackage.Execution.Operators.Access(intlistlist, CorePackage.Entity.Type.Scalar.Integer, intlist);
            CorePackage.Execution.Getter           getfrom       = new CorePackage.Execution.Getter(new CorePackage.Entity.Variable(CorePackage.Entity.Type.Scalar.Integer, 0));

            access.SetInputValue("LeftOperand", val);
            access.SetInputValue("RightOperand", 0);

            intlistappend.GetInput("array").LinkTo(access, "result");
            intlistappend.GetInput("element").LinkTo(getfrom, "reference");
            //intlistappend.SetInputValue("array", val[0]);

            Assert.IsTrue(intlistappend.GetInputValue("array").Count == 0);
            Assert.IsTrue(val[0].Count == 0);
            Assert.IsTrue(val[0] == intlistappend.GetInputValue("array"));

            intlistappend.Execute();

            Assert.IsTrue(intlistappend.GetInputValue("array").Count == 1);
            Assert.IsTrue(val[0].Count == 1);
            Assert.IsTrue(val[0] == intlistappend.GetInputValue("array"));

            List <dynamic> jsonlist = intlist.CreateFromJSON("[3, 9, 1, 2]");

            Assert.IsTrue(intlist.IsValueOfType(jsonlist));
            Assert.IsTrue(jsonlist[0] == 3);
            Assert.IsTrue(jsonlist[1] == 9);
            Assert.IsTrue(jsonlist[2] == 1);
            Assert.IsTrue(jsonlist[3] == 2);
        }
Esempio n. 2
0
        public void TestAdd()
        {
            CorePackage.Entity.Function whileTester = new CorePackage.Entity.Function();

            CorePackage.Entity.Variable j = new CorePackage.Entity.Variable(CorePackage.Entity.Type.Scalar.Floating);
            CorePackage.Entity.Variable l = new CorePackage.Entity.Variable(new CorePackage.Entity.Type.ListType(CorePackage.Entity.Type.Scalar.Floating), new List <double> {
                1.0, 2.0, 42.0
            });

            CorePackage.Execution.Append add = new CorePackage.Execution.Append();
            add.ContainerType = CorePackage.Entity.Type.Scalar.Floating;

            add.GetInput("array").LinkTo(new CorePackage.Execution.Getter(l), "reference");
            add.GetInput("element").LinkTo(new CorePackage.Execution.Getter(j), "reference");

            whileTester.setEntryPoint(whileTester.addInstruction(add));
            whileTester.Call();
            Assert.IsTrue(add.GetOutputValue("count") == 4);
        }