public void WarewolfListIterator_FetchNextValue_WithIndex_HasValues_ShouldReturnValues() { //------------Setup for test-------------------------- var env = new ExecutionEnvironment(); env.Assign("[[rec().a]]", "Test", 0); env.Assign("[[rec().a]]", "Test2", 0); env.Assign("[[rec().a]]", "Test4", 0); env.Assign("[[rec().a]]", "Test5", 0); env.CommitAssign(); //------------Execute Test--------------------------- string value; using (var warewolfListIterator = new WarewolfListIterator()) { var warewolfIterator = new WarewolfIterator(env.Eval("[[rec(3).a]]", 0)); warewolfListIterator.AddVariableToIterateOn(warewolfIterator); value = warewolfListIterator.FetchNextValue(warewolfIterator); //------------Assert Results------------------------- Assert.AreEqual("Test4", value); //------------Execute Test--------------------------- value = warewolfListIterator.FetchNextValue(warewolfIterator); } //------------Assert Results------------------------- Assert.AreEqual("Test4", value); }
public AdvancedRecordset CreatePersonAddressWorkers() { var personRecordsetName = "person"; var addressRecordsetName = "address"; var env = new ExecutionEnvironment(); /* * Person | Name | Age | address_id | | Address | id | Addr | Postcode | | | bob | 21 | 1 | | sue | 22 | 2 | # unique address | jef | 24 | 1 | # matching address | zak | 19 | 9 | # fail finding address | | 1 | 11 test lane | 3421 | | 2 | 16 test lane | 3422 | * */ var l = new List <AssignValue>(); l.Add(new AssignValue("[[person().name]]", "bob")); l.Add(new AssignValue("[[person().age]]", "21")); l.Add(new AssignValue("[[person().address_id]]", "1")); l.Add(new AssignValue("[[person().name]]", "sue")); l.Add(new AssignValue("[[person().age]]", "22")); l.Add(new AssignValue("[[person().address_id]]", "2")); l.Add(new AssignValue("[[person().name]]", "jef")); l.Add(new AssignValue("[[person().age]]", "24")); l.Add(new AssignValue("[[person().address_id]]", "1")); l.Add(new AssignValue("[[person().name]]", "zak")); l.Add(new AssignValue("[[person().age]]", "19")); l.Add(new AssignValue("[[person().address_id]]", "9")); l.Add(new AssignValue("[[address().id]]", "1")); l.Add(new AssignValue("[[address().addr]]", "11 test lane")); l.Add(new AssignValue("[[address().postcode]]", "3421")); l.Add(new AssignValue("[[address().id]]", "2")); l.Add(new AssignValue("[[address().addr]]", "16 test lane")); l.Add(new AssignValue("[[address().postcode]]", "3422")); env.AssignWithFrame(l, 0); env.CommitAssign(); var Worker = new AdvancedRecordset(env); Worker.LoadRecordsetAsTable(personRecordsetName); Worker.LoadRecordsetAsTable(addressRecordsetName); return(Worker); }
public void WarewolfListIterator_GetMax_ShouldReturn1() { var env = new ExecutionEnvironment(); env.Assign("[[rec().a]]", "1", 0); env.Assign("[[rec().a]]", "2", 0); env.Assign("[[rec().a]]", "3", 0); env.Assign("[[rec().a]]", "4", 0); env.CommitAssign(); using (var warewolfListIterator = new WarewolfListIterator()) { var warewolfIterator = new WarewolfIterator(env.Eval("[[rec().a]]", 0)); warewolfListIterator.AddVariableToIterateOn(warewolfIterator); var max = warewolfListIterator.GetMax(); Assert.AreEqual(1, max); } }
public void WarewolfListIterator_FetchNextValue_WithIndex_HasMoreData_ShouldReturnTrue_WhenCounterSmallerThanLargestIndex() { //------------Setup for test-------------------------- var env = new ExecutionEnvironment(); env.Assign("[[rec().a]]", "Test"); env.Assign("[[rec().a]]", "Test2"); env.Assign("[[rec().a]]", "Test4"); env.Assign("[[rec().a]]", "Test5"); env.CommitAssign(); var warewolfListIterator = new WarewolfListIterator(); var warewolfIterator = new WarewolfIterator(env.Eval("[[rec().a]]")); warewolfListIterator.AddVariableToIterateOn(warewolfIterator); //------------Execute Test--------------------------- var hasMoreData = warewolfListIterator.HasMoreData(); //------------Assert Results------------------------- Assert.IsTrue(hasMoreData); }
public static IExecutionEnvironment InputsToEnvironment(IExecutionEnvironment outerEnvironment, string inputDefs, int update) { var env = new ExecutionEnvironment(); try { var inputs = DataListFactory.CreateInputParser().Parse(inputDefs); var inputRecSets = DataListFactory.CreateRecordSetCollection(inputs, false); var inputScalarList = DataListFactory.CreateScalarList(inputs, false); var inputObjectList = DataListFactory.CreateObjectList(inputs); Common.CreateRecordSetsInputs(outerEnvironment, inputRecSets, inputs, env, update); Common.CreateScalarInputs(outerEnvironment, inputScalarList, env, update); Common.CreateObjectInputs(outerEnvironment, inputObjectList, env, update); } finally { env.CommitAssign(); } return(env); }
public void WarewolfListIterator_FetchNextValue_WithScalar_HasValues_ShouldReturnValues() { //------------Setup for test-------------------------- var env = new ExecutionEnvironment(); env.Assign("[[a]]", "Test"); env.CommitAssign(); var warewolfListIterator = new WarewolfListIterator(); var warewolfIterator = new WarewolfIterator(env.Eval("[[a]]")); warewolfListIterator.AddVariableToIterateOn(warewolfIterator); //------------Execute Test--------------------------- var value = warewolfListIterator.FetchNextValue(warewolfIterator); //------------Assert Results------------------------- Assert.AreEqual("Test", value); //------------Execute Test--------------------------- value = warewolfListIterator.FetchNextValue(warewolfIterator); //------------Assert Results------------------------- Assert.AreEqual("Test", value); }