Example #1
0
        public async Task RunWithNotAllowedFunc_Failed()
        {
            var code   = "System.IO.Path.Combine(\"a\",  \"b\");";
            var runner = new CompiledCodeRunner(code, new Container());

            await Assert.ThrowsAsync <Exception>(() => runner.RunAsync());
        }
Example #2
0
        public async Task CorrectCode_ExecutionSucceed()
        {
            var code = "var a = 1; var b = 2; var c = a + b;";

            var runner = new CompiledCodeRunner(code, new Container());
            await runner.RunAsync();
        }
Example #3
0
        static async Task Main()
        {
            using var sr = new StreamReader("input.txt");
            var script = await sr.ReadToEndAsync();

            var runner = new CompiledCodeRunner <GlobalStuff.Globals>(script);
            await runner.RunAsync();
        }
Example #4
0
        public async Task RunWithGlobalVariables_Succeed()
        {
            var t = new HelperObject();

            var container = new Container();

            container.Register(t, "t");

            var code = "t.x++;";

            var runner = new CompiledCodeRunner(code, container);
            await runner.RunAsync();

            Assert.Equal(1, t.x);
        }
Example #5
0
        public async Task ResolveFromContainer_Succeed()
        {
            var    cnt = 0;
            Action f   = () => cnt++;

            var container = new Container();

            container.Register(f, "f");

            var code = "f();";

            var runner = new CompiledCodeRunner(code, container);
            await runner.RunAsync();

            Assert.AreEqual(1, cnt);
        }
Example #6
0
 public async Task Pass()
 {
     var runner = new CompiledCodeRunner("var a = 1;", new Container());
     await runner.RunAsync();
 }