public void Engine_Dynamic_Value_Exists()
        {
            using (var engine = new JsEngine())
            {
                var testLib = new TestLibrary();
                engine.AddLibrary("Dynamic", testLib);

                engine.Execute("Dynamic = lib('Dynamic');");
                Assert.Equal(true, engine.InternalEngine.HasGlobalValue("Dynamic"));
                Assert.Equal(testLib.Property, engine.Evaluate <int>("Dyanmic.Property").Value);
            }
        }
示例#2
0
        public void Engine_Dynamic_Value_Exists()
        {
            var eng = new JsEngine();

            using (var engine = eng.CreateExecutionContext())
            {
                var testLib = new TestLibrary();
                engine.AddLibrary("Dynamic", testLib);

                engine.Execute("Dynamic = require('Dynamic');");
                Assert.NotNull(engine.Resolve("Dynamic"));
                Assert.Equal(testLib.Property, engine.Evaluate <int>("Dyanmic.Property").Value);
            }
        }
        public void Engine_Dynamic_Method_Returns_Clr()
        {
            using (var engine = new JsEngine())
            {
                var testLib = new TestLibrary();
                engine.AddLibrary("Dynamic", testLib);

                engine.Execute("Dynamic = lib('Dynamic');");
                Assert.Equal(true, engine.InternalEngine.HasGlobalValue("Dynamic"));

                var result = engine.Evaluate <int>("Dynamic.MethodReturnClr().Field");

                Assert.Equal(new ClrObject().Field, result.Value);
            }
        }
        public void Engine_Dynamic_Method_Returns()
        {
            using (var engine = new JsEngine())
            {
                var testLib = new TestLibrary();
                engine.AddLibrary("Dynamic", testLib);

                engine.Execute("Dynamic = lib('Dynamic');");
                Assert.Equal(true, engine.InternalEngine.HasGlobalValue("Dynamic"));

                var result = engine.Evaluate <string>("Dynamic.Method()");

                Assert.Equal(testLib.Method(), result.Value);
            }
        }
        public void Engine_Dynamic_Delegate_Func_Fail()
        {
            using (var engine = new JsEngine())
            {
                var testLib = new TestLibrary();
                engine.AddLibrary("Dynamic", testLib);

                engine.Execute("Dynamic = lib('Dynamic');");
                Assert.True(engine.InternalEngine.HasGlobalValue("Dynamic"));

                var result = engine.Evaluate <string>("Dynamic.DelegateWithArguments('Hello')");

                Assert.NotNull(result.ExecutionException);
                //Assert.Equal(testLib.DelegateWithArguments(), result.Value);
            }
        }
        public void Engine_Dynamic_Method_Func_Returns()
        {
            using (var engine = new JsEngine())
            {
                var testLib = new TestLibrary();
                engine.AddLibrary("Dynamic", testLib);

                engine.Execute("Dynamic = lib('Dynamic');");
                Assert.Equal(true, engine.InternalEngine.HasGlobalValue("Dynamic"));

                var result = engine.Evaluate<string>("Dynamic.MethodFunc()");

                Assert.NotNull(result.ExecutionException);
                //Assert.Equal(testLib.MethodFunc()(), result.Value);
            }
        }
        public void Engine_Dynamic_Delegate_Func_Fail()
        {
            using (var engine = new JsEngine())
            {
                var testLib = new TestLibrary();
                engine.AddLibrary("Dynamic", testLib);

                engine.Execute("Dynamic = lib('Dynamic');");
                Assert.True(engine.InternalEngine.HasGlobalValue("Dynamic"));

                var result = engine.Evaluate<string>("Dynamic.DelegateWithArguments('Hello')");

                Assert.NotNull(result.ExecutionException);
                //Assert.Equal(testLib.DelegateWithArguments(), result.Value);
            }
        }
        public void Engine_Dynamic_Delegate_Returns()
        {
            using (var engine = new JsEngine())
            {
                var testLib = new TestLibrary();
                engine.AddLibrary("Dynamic", testLib);

                engine.Execute("import('Dyanmic');");

                engine.Execute("Dynamic = lib('Dynamic');");
                Assert.Equal(true, engine.InternalEngine.HasGlobalValue("Dynamic"));

                var result = engine.Evaluate <int>("Dynamic.Delegate()");

                Assert.Equal(testLib.Property, result.Value);
            }
        }
示例#9
0
        public void Engine_Dynamic_Method_Returns()
        {
            var eng = new JsEngine();

            using (var engine = eng.CreateExecutionContext())
            {
                var testLib = new TestLibrary();
                engine.AddLibrary("Dynamic", testLib);

                engine.Execute("Dynamic = require('Dynamic');");
                Assert.NotNull(engine.Resolve("Dynamic"));

                var result = engine.Evaluate <string>("Dynamic.Method()");

                Assert.Equal(testLib.Method(), result.Value);
            }
        }
示例#10
0
        public void Engine_Dynamic_Method_Returns_Clr()
        {
            var eng = new JsEngine();

            using (var engine = eng.CreateExecutionContext())
            {
                var testLib = new TestLibrary();
                engine.AddLibrary("Dynamic", testLib);

                engine.Execute("Dynamic = require('Dynamic');");
                Assert.NotNull(engine.Resolve("Dynamic"));

                var result = engine.Evaluate <int>("Dynamic.MethodReturnClr().Field");

                Assert.Equal(new ClrObject().Field, result.Value);
            }
        }
示例#11
0
        public void Engine_Dynamic_Delegate_Returns()
        {
            using (var engine = new JsEngine())
            {
                var testLib = new TestLibrary();
                engine.AddLibrary("Dynamic", testLib);

                engine.Execute("import('Dyanmic');");

                engine.Execute("Dynamic = lib('Dynamic');");
                Assert.Equal(true, engine.InternalEngine.HasGlobalValue("Dynamic"));

                var result = engine.Evaluate<int>("Dynamic.Delegate()");

                Assert.Equal(testLib.Property, result.Value);
            }
        }
示例#12
0
        public void Engine_Dynamic_Delegate_Func_Fail()
        {
            var eng = new JsEngine();

            using (var engine = eng.CreateExecutionContext())
            {
                var testLib = new TestLibrary();
                engine.AddLibrary("Dynamic", testLib);

                engine.Execute("Dynamic = require('Dynamic');");
                Assert.NotNull(engine.Resolve("Dynamic"));

                var result = engine.Evaluate <string>("Dynamic.DelegateWithArguments('Hello')");

                //Assert.NotNull(result.ExecutionException);
                Assert.Equal(testLib.DelegateWithArguments("Hello"), result.Value);
            }
        }
示例#13
0
        public void Engine_Dynamic_Delegate_Returns()
        {
            var eng = new JsEngine();

            using (var engine = eng.CreateExecutionContext())
            {
                var testLib = new TestLibrary();
                engine.AddLibrary("Dynamic", testLib);

                engine.Execute("import('Dyanmic');");

                engine.Execute("Dynamic = require('Dynamic');");
                Assert.NotNull(engine.Resolve("Dynamic"));

                var result = engine.Evaluate <int>("Dynamic.Delegate()");

                Assert.Equal(testLib.Property, result.Value);
            }
        }
示例#14
0
        public void Engine_Dynamic_Value_Exists()
        {
            using (var engine = new JsEngine())
            {
                var testLib = new TestLibrary();
                engine.AddLibrary("Dynamic", testLib);

                engine.Execute("Dynamic = lib('Dynamic');");
                Assert.Equal(true, engine.InternalEngine.HasGlobalValue("Dynamic"));
                Assert.Equal(testLib.Property, engine.Evaluate<int>("Dyanmic.Property").Value);
            }
        }
示例#15
0
        public void Engine_Dynamic_Method_WithArg_Returns()
        {
            using (var engine = new JsEngine())
            {
                var testLib = new TestLibrary();
                engine.AddLibrary("Dynamic", testLib);

                engine.Execute("Dynamic = lib('Dynamic');");
                Assert.Equal(true, engine.InternalEngine.HasGlobalValue("Dynamic"));

                var result = engine.Evaluate<string>("Dynamic.MethodWithArg('Hello')");

                Assert.Equal("Hello", result.Value);
            }
        }
示例#16
0
        public void Engine_Dynamic_Method_Returns_ClrArray()
        {
            using (var engine = new JsEngine())
            {
                var testLib = new TestLibrary();
                engine.AddLibrary("Dynamic", testLib);

                engine.Execute("Dynamic = lib('Dynamic');");
                Assert.Equal(true, engine.InternalEngine.HasGlobalValue("Dynamic"));

                var result = engine.Evaluate<int>("Dynamic.MethodReturnClrArray().Length");

                Assert.Equal(2, result.Value);
            }
        }