Exemplo n.º 1
0
        public void Object_Params_Script_Update()
        {
            var globals = new TestArgClass {
                X = 1, Y = 2
            };
            var script =
                @"
let x = (args[0] as TestArgClass).X;
let y = (args[0] as TestArgClass).Y;
(args[0] as TestArgClass).X = x + y;
";
            var result = Parser.Evaluate(script, globals);

            Assert.IsNull(result);
            Assert.AreEqual(3, globals.X);
        }
Exemplo n.º 2
0
        public void Object_Child_Params_Script_Update()
        {
            var globals = new TestArgClass
            {
                Children = new List <TestChildArgClass> {
                    new TestChildArgClass {
                        B = true
                    }, new TestChildArgClass {
                        B = true
                    }, new TestChildArgClass {
                        B = false
                    }
                }
            };
            var script =
                @"
(args[0] as TestArgClass).Children.ToList().ForEach(c => c.B = false);
";
            var result = Parser.Evaluate(script, globals);

            Assert.IsNull(result);
            Assert.IsTrue(globals.Children.All(c => !c.B));
        }