Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
        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);
            }
        }
Ejemplo n.º 7
0
        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);
            }
        }
Ejemplo n.º 8
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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }