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 AdvancedRecordsetActivity_ExecuteRecordset_GIVEN_JsonObject_ShouldSuccess() { var started = false; var personRecordsetName = "personRec"; var env = CreateExecutionEnvironment(); var personObject = new List <AssignValue> { new AssignValue("[[@person()]]", "{'name':'bob', 'age':21, 'address_id':'1'}") }; env.AssignWithFrame(personObject, 0); env.CommitAssign(); var personRec = new List <AssignValue> { new AssignValue("[[personRec().name]]", "[[@person(*).name]]") }; env.AssignWithFrame(personRec, 0); env.CommitAssign(); var recordset = new AdvancedRecordset(env); recordset.LoadRecordsetAsTable(personRecordsetName); var activity = new AdvancedRecordsetActivity() { SqlQuery = "Select * from personRec", Outputs = new List <IServiceOutputMapping> { new ServiceOutputMapping { MappedFrom = "name", MappedTo = "[[TableCopy().name]]", } } }; var worker = new AdvancedRecordsetActivityWorker(activity, recordset); var dataObject = new Mock <IDSFDataObject>(); dataObject.Setup(o => o.IsDebugMode()).Returns(true); dataObject.Setup(o => o.Environment).Returns(env); dataObject.Object.Environment = env; worker.ExecuteRecordset(dataObject.Object, 0); var result = env.Eval("[[TableCopy(1).name]]", 0); Assert.AreEqual("bob", ExecutionEnvironment.WarewolfEvalResultToString(result)); }
public void AdvancedRecordset_LoadRecordsetAsTable_LoadIntoSqliteDb_BuildInsertStatement_colTypeTests() { var personRecordsetName = "person"; var l = new List <AssignValue>(); l.Add(new AssignValue("[[person().datatypesFloat]]", "4.5f")); l.Add(new AssignValue("[[person().testNothing]]", "")); l.Add(new AssignValue("[[person().testWarewolfAtom]]", "1")); var env = CreateExecutionEnvironment(); env.AssignWithFrame(l, 0); env.CommitAssign(); var advancedRecordset = new AdvancedRecordset(env); advancedRecordset.LoadRecordsetAsTable(personRecordsetName); Assert.IsNotNull(advancedRecordset); }
public void AdvancedRecordsetActivity_ExecuteRecordset() { var started = false; var personRecordsetName = "person"; 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")); var env = CreateExecutionEnvironment(); env.AssignWithFrame(l, 0); env.CommitAssign(); var recordset = new AdvancedRecordset(env); recordset.LoadRecordsetAsTable(personRecordsetName); recordset.ApplyResultToEnvironment(personRecordsetName, new List <IServiceOutputMapping>(), new List <DataRow>(), false, 0, ref started); recordset.CreateVariableTable(); recordset.InsertIntoVariableTable("TestVariable", "testdata"); var activity = new AdvancedRecordsetActivity() { SqlQuery = "Select * from person", }; var worker = new AdvancedRecordsetActivityWorker(activity, recordset); var dataObject = new Mock <IDSFDataObject>(); dataObject.Setup(o => o.IsDebugMode()).Returns(true); dataObject.Setup(o => o.Environment).Returns(env); dataObject.Object.Environment = env; //TODO: this is failing as it needs a mock of the recorset // worker.ExecuteRecordset(dataObject.Object, 0) }