public void TestReadFile() { var fs = new PlotLingoLib.Expressions.FunctionExpression("readfile", new StringValue("TestReadFile.txt")); var c = new RootContext(); var r = fs.Evaluate(c); Assert.AreEqual("hi\r\nthere", r, "content of file"); }
public void ReadFromFileNearPlotLingoScript() { if (Directory.Exists("ReadFromScriptFile")) { Directory.Delete("ReadFromScriptFile", true); } var dirinfo = Directory.CreateDirectory("ReadFromScriptFile"); File.Copy("TestReadFile.txt", @"ReadFromScriptFile\read.txt"); var fs = new PlotLingoLib.Expressions.FunctionExpression("readfile", new StringValue("read.txt")); var c = new RootContext(); c.ExecutionContext.ScriptFileContextPush(new FileInfo(string.Format(@"{0}\bogus.plotlingo", dirinfo.FullName))); var r = fs.Evaluate(c); Assert.AreEqual("hi\r\nthere", r, "content of file"); }