Exemple #1
0
        public void VBScriptEngine_Script_Variable()
        {
            var host = new HostFunctions();

            engine.Script.host = host;
            Assert.AreSame(host, engine.Script.host);
        }
            public static void VerifyAsymmetric <TValue>(HostFunctions host, TValue value)
            {
                var result1 = VerifyCast <TTarget>(host, value);
                var result2 = VerifyCast <TValue>(host, result1);

                Assert.AreEqual(value.DynamicCast <TTarget>().DynamicCast <TValue>(), result2);
            }
        public void JScriptEngine_Script_Property()
        {
            var host = new HostFunctions();

            engine.Script.host = host;
            Assert.AreSame(host, engine.Script.host);
        }
Exemple #4
0
        public void VBScriptEngine_AddHostObject()
        {
            var host = new HostFunctions();

            engine.AddHostObject("host", host);
            Assert.AreSame(host, engine.Evaluate("host"));
        }
Exemple #5
0
        public object InvokeFunction(string _Name, object[] args)
        {
            var host = new HostFunctions();

            ((IScriptableObject)host).OnExposedToScriptCode(this);
            var del = (Delegate)host.func <object>(args.Length, Script[_Name]);

            return(del.DynamicInvoke(args));
        }
Exemple #6
0
        public void PropertyBag_Property()
        {
            var host = new HostFunctions();
            var bag  = new PropertyBag {
                { "host", host }
            };

            engine.AddHostObject("bag", bag);
            Assert.AreSame(host, engine.Evaluate("bag.host"));
        }
Exemple #7
0
        public void PropertyBag_Property_GlobalMembers()
        {
            var host = new HostFunctions();
            var bag  = new PropertyBag {
                { "host", host }
            };

            engine.AddHostObject("bag", HostItemFlags.GlobalMembers, bag);
            Assert.AreSame(host, engine.Evaluate("host"));
        }
Exemple #8
0
        public void PropertyBag_IScriptableObject_OnExpose()
        {
            var host = new HostFunctions();
            var bag  = new PropertyBag {
                { "host", host }
            };

            engine.AddHostObject("bag", bag);
            Assert.AreSame(engine, host.GetEngine());
        }
Exemple #9
0
        public void PropertyBag_IScriptableObject_OnModify()
        {
            var bag = new PropertyBag();

            engine.AddHostObject("bag", bag);
            var host = new HostFunctions();

            bag.Add("host", host);
            Assert.AreSame(engine, host.GetEngine());
        }
Exemple #10
0
        public void VBScriptEngine_AddHostObject_GlobalMembers()
        {
            var host = new HostFunctions();

            engine.AddHostObject("host", HostItemFlags.GlobalMembers, host);
            Assert.IsInstanceOfType(engine.Evaluate("newObj()"), typeof(PropertyBag));

            engine.AddHostObject("test", HostItemFlags.GlobalMembers, this);
            engine.Execute("TestProperty = newObj()");
            Assert.IsInstanceOfType(TestProperty, typeof(PropertyBag));
        }
Exemple #11
0
        public static object[] Call(string func, params object[] p)
        {
            var ret = new List <object>();

            var host = new HostFunctions();

            ((IScriptableObject)host).OnExposedToScriptCode(_engine);
            var del = (Delegate)host.func <object>(p.Length, _engine.Script[func]);

            ret.Add(del.DynamicInvoke(p));

            return(ret.ToArray());
        }
            private static object VerifyCast <T>(HostFunctions host, object value)
            {
                var expectedResult = value.DynamicCast <T>();

                var result   = host.cast <T>(value);
                var hostItem = result as HostItem;

                if (hostItem != null)
                {
                    Assert.AreEqual(typeof(T), hostItem.Target.Type);
                    result = hostItem.Unwrap();
                }

                Assert.AreEqual(expectedResult, result);
                return(result);
            }
 public void TestInitialize()
 {
     engine = new JScriptEngine(WindowsScriptEngineFlags.EnableDebugging);
     engine.AddHostObject("host", host = new HostFunctions());
 }
 public void V8ScriptEngine_Script_Property()
 {
     var host = new HostFunctions();
     engine.Script.host = host;
     Assert.AreSame(host, engine.Script.host);
 }
 public void PropertyBag_IScriptableObject_OnModify()
 {
     var bag = new PropertyBag();
     engine.AddHostObject("bag", bag);
     var host = new HostFunctions();
     bag.Add("host", host);
     Assert.AreSame(engine, host.GetEngine());
 }
 public void PropertyBag_IScriptableObject_OnExpose()
 {
     var host = new HostFunctions();
     var bag = new PropertyBag { { "host", host } };
     engine.AddHostObject("bag", bag);
     Assert.AreSame(engine, host.GetEngine());
 }
 public void PropertyBag_Property()
 {
     var host = new HostFunctions();
     var bag = new PropertyBag { { "host", host } };
     engine.AddHostObject("bag", bag);
     Assert.AreSame(host, engine.Evaluate("bag.host"));
 }
 public void PropertyBag_Property_GlobalMembers()
 {
     var host = new HostFunctions();
     var bag = new PropertyBag { { "host", host } };
     engine.AddHostObject("bag", HostItemFlags.GlobalMembers, bag);
     Assert.AreSame(host, engine.Evaluate("host"));
 }
 public static object VerifyCast(HostFunctions host, object value)
 {
     return(VerifyCast <TTarget>(host, value));
 }
        public void VBScriptEngine_AddHostObject_GlobalMembers()
        {
            var host = new HostFunctions();
            engine.AddHostObject("host", HostItemFlags.GlobalMembers, host);
            Assert.IsInstanceOfType(engine.Evaluate("newObj()"), typeof(PropertyBag));

            engine.AddHostObject("test", HostItemFlags.GlobalMembers, this);
            engine.Execute("TestProperty = newObj()");
            Assert.IsInstanceOfType(TestProperty, typeof(PropertyBag));
        }
 public void VBScriptEngine_AddHostObject()
 {
     var host = new HostFunctions();
     engine.AddHostObject("host", host);
     Assert.AreSame(host, engine.Evaluate("host"));
 }
 public void VBScriptEngine_Script_Variable()
 {
     var host = new HostFunctions();
     engine.Script.host = host;
     Assert.AreSame(host, engine.Script.host);
 }
Exemple #23
0
 public void BugFix_HostItemCachingForHostVariables()
 {
     var foo = new HostFunctions().newVar(new object());
     engine.Script.foo1 = foo;
     engine.Script.foo2 = foo;
     Assert.IsTrue(Convert.ToBoolean(engine.Evaluate("foo1 === foo2")));
 }