Ejemplo n.º 1
0
        public void BaseAssignment()
        {
            RuntimeHost.AddType("TestT", typeof(TestT));
            ScriptContext context = new ScriptContext();

            TestT rez = (TestT)Script.RunCode(@"
         a = new TestT();
         a.value = 'test';
         a.intVal = 20;

         return a;
      ", context);

            Assert.AreEqual(20, rez.intVal);
            Assert.AreEqual("test", rez.value);
        }
Ejemplo n.º 2
0
        public void AssignmentToEvaluatedObject()
        {
            ScriptContext context = new ScriptContext();
            //context.AddType("TestT", typeof(TestT));

            TestT rez = (TestT)Script.RunCode(@"
         a = new TestT();
         a.GetThis().value = 'test';
         a.GetThis().intVal = 20;

         return a;
      ", context);

            Assert.AreEqual(20, rez.intVal);
            Assert.AreEqual("test", rez.value);
        }
Ejemplo n.º 3
0
        public void AssignmentToArrayObjectReturnedByFunctionCall()
        {
            TestT      obj  = new TestT();
            List <int> list = new List <int>();

            list.AddRange(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 });
            obj.testObject = list;

            ScriptContext context = new ScriptContext();

            //context.AddType("TestT", typeof(TestT));
            context.SetItem("a", obj);

            TestT rez = (TestT)Script.RunCode(@"
         a.GetTestObject()[3] = 16;
         return a;
      ", context);

            Assert.AreEqual(16, list[3]);
        }