public IEnumerable <Tuple <string, DataStorage.WarewolfAtom>[]> EvalAsTable(string recordsetExpression, int update, bool throwsifnotexists) { var result = PublicFunctions.EvalEnvExpressionToTable(recordsetExpression, update, _env, throwsifnotexists); return(result); }
public void PublicFunctionsEvalEnvExpressionToTable() { //------------Setup for test-------------------------- var env = CreateEnvironmentWithData(); var lst = new List <DataStorage.WarewolfAtom> { DataStorage.WarewolfAtom.Nothing, DataStorage.WarewolfAtom.NewPositionedValue(new Tuple <int, DataStorage.WarewolfAtom>(2, DataStorage.WarewolfAtom.NewDataString("a"))), DataStorage.WarewolfAtom.NewDataString("A") }; //------------Execute Test--------------------------- var res = PublicFunctions.EvalEnvExpressionToTable("[[Rec(*)]]", 0, env, true); Assert.IsNotNull(res); var allTestData = new[] { new[] { new[] { "a", "1" }, new[] { "b", "a" }, }, new[] { new[] { "a", "2" }, new[] { "b", "b" }, }, new[] { new[] { "a", "3" }, new[] { "b", "c" }, }, new[] { new[] { "a", "2" }, new[] { "b", "c" }, }, }; Assert.AreEqual(4, res.Count()); var combined = allTestData.Zip(res, (test, result) => (test, result)); foreach (var(testdata, rowTuple) in combined) { var index = 0; foreach (var(field, value) in rowTuple) { Assert.IsTrue(field == testdata[index][0]); Assert.IsTrue(value.Equals(testdata[index][1])); index++; } } }