Ejemplo n.º 1
0
        public void RunningFile()
        {
            var path = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".lua";

            using (var file = File.OpenWrite(path)) {
                using (var writer = new StreamWriter(file)) {
                    writer.Write(@"
                        return 'Hello, world!'
                    ");
                }
            }

            using (var runtime = new LuaRuntime()) {
                using (var result = runtime.DoFile(path)) {
                    using (var func = runtime.CompileFile(path)) {
                        using (var result2 = func.Call()) {
                            Assert.AreEqual(result.Count, 1);
                            Assert.AreEqual(result2.Count, 1);
                            Assert.AreEqual(result[0], result2[0]);
                        }
                    }
                }
            }

            File.Delete(path);
        }