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()); }
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(); }
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(); }
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); }
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); }
public async Task Pass() { var runner = new CompiledCodeRunner("var a = 1;", new Container()); await runner.RunAsync(); }