protected override void BuildDataList() { List<Tuple<string, string>> variableList; ScenarioContext.Current.TryGetValue("variableList", out variableList); if(variableList == null) { variableList = new List<Tuple<string, string>>(); ScenarioContext.Current.Add("variableList", variableList); } variableList.Add(new Tuple<string, string>(ResultVariable, "")); BuildShapeAndTestData(); var dataMerge = new DsfDataMergeActivity { Result = ResultVariable }; List<Tuple<string, string, string, string, string>> mergeCollection; ScenarioContext.Current.TryGetValue("mergeCollection", out mergeCollection); int row = 1; foreach(var variable in mergeCollection) { dataMerge.MergeCollection.Add(new DataMergeDTO(variable.Item1, variable.Item2, variable.Item3, row, variable.Item4, variable.Item5)); row++; } TestStartNode = new FlowStep { Action = dataMerge }; ScenarioContext.Current.Add("activity", dataMerge); }
protected override void BuildDataList() { scenarioContext.TryGetValue("variableList", out List <Tuple <string, string> > variableList); if (variableList == null) { variableList = new List <Tuple <string, string> >(); scenarioContext.Add("variableList", variableList); } variableList.Add(new Tuple <string, string>(ResultVariable, "")); BuildShapeAndTestData(); var dataMerge = new DsfDataMergeActivity { Result = ResultVariable }; scenarioContext.TryGetValue("mergeCollection", out List <Tuple <string, string, string, string, string> > mergeCollection); var row = 1; foreach (var variable in mergeCollection) { dataMerge.MergeCollection.Add(new DataMergeDTO(variable.Item1, variable.Item2, variable.Item3, row, variable.Item4, variable.Item5)); row++; } TestStartNode = new FlowStep { Action = dataMerge }; scenarioContext.Add("activity", dataMerge); }
public void GetActivityFieldsOffDataMergeActivityExpectedAllFindMissingFieldsToBeReturned() { DsfDataMergeActivity dataMergeActivity = new DsfDataMergeActivity(); dataMergeActivity.OnErrorVariable = "[[onErr]]"; dataMergeActivity.MergeCollection = new List<DataMergeDTO> { new DataMergeDTO("[[InputVariable1]]", "None", "[[At1]]", 1, "[[Padding1]]", "Left"), new DataMergeDTO("[[InputVariable2]]", "None", "[[At2]]", 2, "[[Padding2]]", "Left") }; dataMergeActivity.Result = "[[Result]]"; Dev2FindMissingStrategyFactory fac = new Dev2FindMissingStrategyFactory(); IFindMissingStrategy strategy = fac.CreateFindMissingStrategy(enFindMissingType.MixedActivity); List<string> actual = strategy.GetActivityFields(dataMergeActivity); List<string> expected = new List<string> { "[[Padding1]]", "[[InputVariable1]]", "[[At1]]", "[[Padding2]]", "[[InputVariable2]]", "[[At2]]", "[[Result]]", "[[onErr]]" }; CollectionAssert.AreEqual(expected, actual); }
public void DsfDataMergeActivity_GetOutputs_Called_ShouldReturnListWithResultValueInIt() { //------------Setup for test-------------------------- var act = new DsfDataMergeActivity { Result = "[[res]]", MergeCollection = _mergeCollection }; //------------Execute Test--------------------------- var outputs = act.GetOutputs(); //------------Assert Results------------------------- Assert.AreEqual(1, outputs.Count); Assert.AreEqual("[[res]]", outputs[0]); }
public void DsfDataMergeActivity_UpdateForEachOutputs_NullUpdates_DoesNothing() { //------------Setup for test-------------------------- _mergeCollection.Clear(); _mergeCollection.Add(new DataMergeDTO("[[CompanyName]]", "Chars", ",", 1, " ", "Left")); DsfDataMergeActivity act = new DsfDataMergeActivity { Result = "[[res]]", MergeCollection = _mergeCollection }; //------------Execute Test--------------------------- act.UpdateForEachOutputs(null); //------------Assert Results------------------------- Assert.AreEqual("[[res]]", act.Result); }
public void Equals_Given_Different_MergeCollection_Is_Not_Equal() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var mergeColl = new List <DataMergeDTO> { new DataMergeDTO { InputVariable = "[[VariableA]]" , At = "'" , MergeType = "CHAR" , Alignment = "RIGHT" } }; var mergeColl2 = new List <DataMergeDTO>() { new DataMergeDTO { InputVariable = "[[VariableA]]" , At = "'" , MergeType = "CHAR" , Alignment = "LEFT" } }; var activity1 = new DsfDataMergeActivity() { UniqueID = uniqueId, MergeCollection = mergeColl }; var activity = new DsfDataMergeActivity() { UniqueID = uniqueId, MergeCollection = mergeColl2 }; //---------------Assert Precondition---------------- Assert.IsNotNull(activity1); //---------------Execute Test ---------------------- var @equals = activity1.Equals(activity); //---------------Test Result ----------------------- Assert.IsFalse(@equals); }
public void DsfDataMergeActivity_GetState_Returns_Inputs_And_Outputs() { //------------Setup for test-------------------------- _mergeCollection.Clear(); _mergeCollection.Add(new DataMergeDTO("[[CompanyName]]", "Chars", ",", 1, " ", "Left")); var act = new DsfDataMergeActivity { Result = "[[res]]", MergeCollection = _mergeCollection }; //------------Execute Test--------------------------- var stateItems = act.GetState(); //------------Assert Results------------------------- Assert.AreEqual(2, stateItems.Count()); var expectedResults = new[] { new StateVariable { Name = "Merge Collection", Type = StateVariable.StateType.Input, Value = ActivityHelper.GetSerializedStateValueFromCollection(_mergeCollection) }, new StateVariable { Name = "Result", Type = StateVariable.StateType.Output, Value = act.Result } }; var iter = act.GetState().Select( (item, index) => new { value = item, expectValue = expectedResults[index] } ); //------------Assert Results------------------------- foreach (var entry in iter) { Assert.AreEqual(entry.expectValue.Name, entry.value.Name); Assert.AreEqual(entry.expectValue.Type, entry.value.Type); Assert.AreEqual(entry.expectValue.Value, entry.value.Value); } }
public void DsfDataMergeActivity_GetForEachOutputs_WhenHasResult_ReturnsInputList() { //------------Setup for test-------------------------- _mergeCollection.Clear(); _mergeCollection.Add(new DataMergeDTO("[[CompanyName]]", "Chars", ",", 1, " ", "Left")); DsfDataMergeActivity act = new DsfDataMergeActivity { Result = "[[res]]", MergeCollection = _mergeCollection }; //------------Execute Test--------------------------- var dsfForEachItems = act.GetForEachOutputs(); //------------Assert Results------------------------- Assert.AreEqual(1, dsfForEachItems.Count); Assert.AreEqual("[[res]]", dsfForEachItems[0].Name); Assert.AreEqual("[[res]]", dsfForEachItems[0].Value); }
public void DsfDataMergeActivity_UpdateForEachOutputs_1Updates_UpdateCountNumber() { //------------Setup for test-------------------------- _mergeCollection.Clear(); _mergeCollection.Add(new DataMergeDTO("[[CompanyName]]", "Chars", ",", 1, " ", "Left")); DsfDataMergeActivity act = new DsfDataMergeActivity { Result = "[[res]]", MergeCollection = _mergeCollection }; var tuple1 = new Tuple <string, string>("[[res]]", "Test"); //------------Execute Test--------------------------- act.UpdateForEachOutputs(new List <Tuple <string, string> > { tuple1 }); //------------Assert Results------------------------- Assert.AreEqual("Test", act.Result); }
public void GetActivityFieldsOffDataMergeActivityExpectedAllFindMissingFieldsToBeReturned() { DsfDataMergeActivity dataMergeActivity = new DsfDataMergeActivity(); dataMergeActivity.OnErrorVariable = "[[onErr]]"; dataMergeActivity.MergeCollection = new List <DataMergeDTO> { new DataMergeDTO("[[InputVariable1]]", "None", "[[At1]]", 1, "[[Padding1]]", "Left"), new DataMergeDTO("[[InputVariable2]]", "None", "[[At2]]", 2, "[[Padding2]]", "Left") }; dataMergeActivity.Result = "[[Result]]"; Dev2FindMissingStrategyFactory fac = new Dev2FindMissingStrategyFactory(); IFindMissingStrategy strategy = fac.CreateFindMissingStrategy(enFindMissingType.MixedActivity); List <string> actual = strategy.GetActivityFields(dataMergeActivity); List <string> expected = new List <string> { "[[Padding1]]", "[[InputVariable1]]", "[[At1]]", "[[Padding2]]", "[[InputVariable2]]", "[[At2]]", "[[Result]]", "[[onErr]]" }; CollectionAssert.AreEqual(expected, actual); }
public void GivenItContainsDataMergeAs(string parentName, string activityName, string resultVariable, Table table) { var activity = new DsfDataMergeActivity { Result = resultVariable, DisplayName = activityName }; foreach (var tableRow in table.Rows) { var variable = tableRow["Variable"]; var type = tableRow["Type"]; var at = tableRow["Using"]; var padding = tableRow["Padding"]; var alignment = tableRow["Alignment"]; activity.MergeCollection.Add(new DataMergeDTO(variable, type, at, 1, padding, alignment, true)); } _commonSteps.AddVariableToVariableList(resultVariable); _commonSteps.AddActivityToActivityList(parentName, activityName, activity); }
public void Equals_Given_EmptyActivityTools_AreEqual() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var activity = new DsfDataMergeActivity() { UniqueID = uniqueId }; var activity1 = new DsfDataMergeActivity() { UniqueID = uniqueId }; //---------------Assert Precondition---------------- Assert.IsNotNull(activity); //---------------Execute Test ---------------------- var @equals = activity.Equals(activity1); //---------------Test Result ----------------------- Assert.IsTrue(@equals); }
public void Equals_Given_Different_DisplayName_Is_Not_Equal() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var activity1 = new DsfDataMergeActivity() { UniqueID = uniqueId, DisplayName = "A" }; var activity = new DsfDataMergeActivity() { UniqueID = uniqueId, DisplayName = "ass" }; //---------------Assert Precondition---------------- Assert.IsNotNull(activity1); //---------------Execute Test ---------------------- var @equals = activity1.Equals(activity); //---------------Test Result ----------------------- Assert.IsFalse(@equals); }
public void DsfDataMergeActivity_UpdateForEachInputs_MoreThan1Updates_UpdatesMergeCollection() { //------------Setup for test-------------------------- _mergeCollection.Clear(); _mergeCollection.Add(new DataMergeDTO("[[CompanyName]]", "Chars", ",", 1, " ", "Left")); _mergeCollection.Add(new DataMergeDTO("[[CompanyNumber]]", "Chars", ",", 2, " ", "Left")); var act = new DsfDataMergeActivity { Result = "[[res]]", MergeCollection = _mergeCollection }; var tuple1 = new Tuple <string, string>("[[CompanyName]]", "Test"); var tuple2 = new Tuple <string, string>("[[CompanyNumber]]", "Test2"); //------------Execute Test--------------------------- act.UpdateForEachInputs(new List <Tuple <string, string> > { tuple1, tuple2 }); //------------Assert Results------------------------- Assert.AreEqual("Test", act.MergeCollection[0].InputVariable); Assert.AreEqual("Test2", act.MergeCollection[1].InputVariable); }
public void Equals_Given_Same_MergeCollection_IsEqual() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var mergeColl = new List <DataMergeDTO>(); var activity1 = new DsfDataMergeActivity() { UniqueID = uniqueId, MergeCollection = mergeColl }; var activity = new DsfDataMergeActivity() { UniqueID = uniqueId, MergeCollection = mergeColl }; //---------------Assert Precondition---------------- Assert.IsNotNull(activity1); //---------------Execute Test ---------------------- var @equals = activity1.Equals(activity); //---------------Test Result ----------------------- Assert.IsTrue(@equals); }
public void SequenceActivityFindMissingStrategy_GetActivityFields_WithAssignAndDataMerge_ReturnsAllVariables() { //------------Setup for test-------------------------- var multiAssignActivity = new DsfMultiAssignActivity { FieldsCollection = new List <ActivityDTO> { new ActivityDTO("[[AssignRight1]]", "[[AssignLeft1]]", 1), new ActivityDTO("[[AssignRight2]]", "[[AssignLeft2]]", 2) } }; var dataMergeActivity = new DsfDataMergeActivity { Result = "[[Result]]" }; dataMergeActivity.MergeCollection.Add(new DataMergeDTO("[[rec().a]]", "Index", "6", 1, "[[b]]", "Left")); var dsfActivity = new DsfActivity { InputMapping = @"<Inputs><Input Name=""reg"" Source=""NUD2347"" DefaultValue=""NUD2347""><Validator Type=""Required"" /></Input><Input Name=""asdfsad"" Source=""registration223"" DefaultValue=""w3rt24324""><Validator Type=""Required"" /></Input><Input Name=""number"" Source=""[[number]]"" /></Inputs>", OutputMapping = @"<Outputs><Output Name=""vehicleVin"" MapsTo=""VIN"" Value="""" /><Output Name=""vehicleColor"" MapsTo=""VehicleColor"" Value="""" /><Output Name=""speed"" MapsTo=""speed"" Value="""" Recordset=""Fines"" /><Output Name=""date"" MapsTo=""date"" Value=""Fines.Date"" Recordset=""Fines"" /><Output Name=""location"" MapsTo=""location"" Value="""" Recordset=""Fines"" /></Outputs>" }; var forEachActivity = new DsfForEachActivity { ForEachElementName = "5", DataFunc = { Handler = dsfActivity } }; var activity = new DsfSequenceActivity(); activity.Activities.Add(multiAssignActivity); activity.Activities.Add(dataMergeActivity); activity.Activities.Add(forEachActivity); var fac = new Dev2FindMissingStrategyFactory(); var strategy = fac.CreateFindMissingStrategy(enFindMissingType.Sequence); //------------Execute Test--------------------------- var actual = strategy.GetActivityFields(activity); //------------Assert Results------------------------- var expected = new List <string> { "[[AssignRight1]]", "[[AssignLeft1]]", "[[AssignRight2]]", "[[AssignLeft2]]", "[[b]]", "[[rec().a]]", "6", "[[Result]]", "NUD2347", "registration223", "[[number]]", "Fines.Date", "5" }; CollectionAssert.AreEqual(expected, actual); }
public void SequenceActivityFindMissingStrategy_GetActivityFields_WithAssignAndDataMerge_ReturnsAllVariables() { //------------Setup for test-------------------------- DsfMultiAssignActivity multiAssignActivity = new DsfMultiAssignActivity { FieldsCollection = new List<ActivityDTO> { new ActivityDTO("[[AssignRight1]]", "[[AssignLeft1]]", 1), new ActivityDTO("[[AssignRight2]]", "[[AssignLeft2]]", 2) } }; DsfDataMergeActivity dataMergeActivity = new DsfDataMergeActivity { Result = "[[Result]]" }; dataMergeActivity.MergeCollection.Add(new DataMergeDTO("[[rec().a]]", "Index", "6", 1, "[[b]]", "Left")); DsfActivity dsfActivity = new DsfActivity { InputMapping = @"<Inputs><Input Name=""reg"" Source=""NUD2347"" DefaultValue=""NUD2347""><Validator Type=""Required"" /></Input><Input Name=""asdfsad"" Source=""registration223"" DefaultValue=""w3rt24324""><Validator Type=""Required"" /></Input><Input Name=""number"" Source=""[[number]]"" /></Inputs>", OutputMapping = @"<Outputs><Output Name=""vehicleVin"" MapsTo=""VIN"" Value="""" /><Output Name=""vehicleColor"" MapsTo=""VehicleColor"" Value="""" /><Output Name=""speed"" MapsTo=""speed"" Value="""" Recordset=""Fines"" /><Output Name=""date"" MapsTo=""date"" Value=""Fines.Date"" Recordset=""Fines"" /><Output Name=""location"" MapsTo=""location"" Value="""" Recordset=""Fines"" /></Outputs>" }; DsfForEachActivity forEachActivity = new DsfForEachActivity { ForEachElementName = "5", DataFunc = { Handler = dsfActivity } }; DsfSequenceActivity activity = new DsfSequenceActivity(); activity.Activities.Add(multiAssignActivity); activity.Activities.Add(dataMergeActivity); activity.Activities.Add(forEachActivity); Dev2FindMissingStrategyFactory fac = new Dev2FindMissingStrategyFactory(); IFindMissingStrategy strategy = fac.CreateFindMissingStrategy(enFindMissingType.Sequence); //------------Execute Test--------------------------- List<string> actual = strategy.GetActivityFields(activity); //------------Assert Results------------------------- List<string> expected = new List<string> { "[[AssignRight1]]", "[[AssignLeft1]]", "[[AssignRight2]]", "[[AssignLeft2]]", "[[b]]", "[[rec().a]]", "6", "[[Result]]", "NUD2347", "registration223", "[[number]]", "Fines.Date", "5" }; CollectionAssert.AreEqual(expected, actual); }
public void GivenItContainsDataMergeAs(string parentName, string activityName, string resultVariable, Table table) { DsfDataMergeActivity activity = new DsfDataMergeActivity { Result = resultVariable, DisplayName = activityName }; foreach(var tableRow in table.Rows) { var variable = tableRow["Variable"]; var type = tableRow["Type"]; var at = tableRow["Using"]; var padding = tableRow["Padding"]; var alignment = tableRow["Alignment"]; activity.MergeCollection.Add(new DataMergeDTO(variable, type, at, 1, padding, alignment, true)); } CommonSteps.AddVariableToVariableList(resultVariable); CommonSteps.AddActivityToActivityList(parentName, activityName, activity); }
public void DsfDataMergeActivity_UpdateForEachInputs_MoreThan1Updates_UpdatesMergeCollection() { //------------Setup for test-------------------------- _mergeCollection.Clear(); _mergeCollection.Add(new DataMergeDTO("[[CompanyName]]", "Chars", ",", 1, " ", "Left")); _mergeCollection.Add(new DataMergeDTO("[[CompanyNumber]]", "Chars", ",", 2, " ", "Left")); var act = new DsfDataMergeActivity { Result = "[[res]]", MergeCollection = _mergeCollection }; var tuple1 = new Tuple<string, string>("[[CompanyName]]", "Test"); var tuple2 = new Tuple<string, string>("[[CompanyNumber]]", "Test2"); //------------Execute Test--------------------------- act.UpdateForEachInputs(new List<Tuple<string, string>> { tuple1, tuple2 }); //------------Assert Results------------------------- Assert.AreEqual("Test", act.MergeCollection[0].InputVariable); Assert.AreEqual("Test2", act.MergeCollection[1].InputVariable); }
public void DsfDataMergeActivity_UpdateForEachOutputs_1Updates_UpdateCountNumber() { //------------Setup for test-------------------------- _mergeCollection.Clear(); _mergeCollection.Add(new DataMergeDTO("[[CompanyName]]", "Chars", ",", 1, " ", "Left")); DsfDataMergeActivity act = new DsfDataMergeActivity { Result = "[[res]]", MergeCollection = _mergeCollection }; var tuple1 = new Tuple<string, string>("[[res]]", "Test"); //------------Execute Test--------------------------- act.UpdateForEachOutputs(new List<Tuple<string, string>> { tuple1 }); //------------Assert Results------------------------- Assert.AreEqual("Test", act.Result); }
/// <summary> /// Gets all the fields for a specific activity /// </summary> /// <param name="activity">The activity that the fields will be retrieved from</param> /// <returns>Returns all the fields in a list of strings</returns> public List <string> GetActivityFields(object activity) { List <string> results = new List <string>(); Type activityType = activity.GetType(); if (activityType == typeof(DsfDataSplitActivity)) { DsfDataSplitActivity dsAct = activity as DsfDataSplitActivity; if (dsAct != null) { results.AddRange(InternalFindMissing(dsAct.ResultsCollection)); if (!string.IsNullOrEmpty(dsAct.SourceString)) { results.Add(dsAct.SourceString); } } } if (activityType == typeof(DsfCreateJsonActivity)) { var dsAct = activity as DsfCreateJsonActivity; if (dsAct != null) { results.AddRange(InternalFindMissing(dsAct.JsonMappings)); if (!string.IsNullOrEmpty(dsAct.JsonString)) { results.Add(dsAct.JsonString); } } } if (activityType == typeof(SharepointReadListActivity)) { var dsAct = activity as SharepointReadListActivity; if (dsAct != null) { results.AddRange(InternalFindMissing(dsAct.ReadListItems)); if (dsAct.FilterCriteria != null) { results.AddRange(InternalFindMissing(dsAct.FilterCriteria)); } } } if (activityType == typeof(SharepointCreateListItemActivity)) { var dsAct = activity as SharepointCreateListItemActivity; if (dsAct != null) { results.AddRange(InternalFindMissing(dsAct.ReadListItems)); results.Add(dsAct.Result); } } if (activityType == typeof(SharepointDeleteListItemActivity)) { var dsAct = activity as SharepointDeleteListItemActivity; if (dsAct != null) { results.AddRange(InternalFindMissing(dsAct.FilterCriteria)); results.Add(dsAct.DeleteCount); } } if (activityType == typeof(SharepointUpdateListItemActivity)) { var dsAct = activity as SharepointUpdateListItemActivity; if (dsAct != null) { results.AddRange(InternalFindMissing(dsAct.ReadListItems)); results.AddRange(InternalFindMissing(dsAct.FilterCriteria)); results.Add(dsAct.Result); } } else if (activityType == typeof(DsfDataMergeActivity)) { DsfDataMergeActivity dmAct = activity as DsfDataMergeActivity; if (dmAct != null) { results.AddRange(InternalFindMissing(dmAct.MergeCollection)); if (!string.IsNullOrEmpty(dmAct.Result)) { results.Add(dmAct.Result); } } } else if (activityType == typeof(DsfXPathActivity)) { DsfXPathActivity xpAct = activity as DsfXPathActivity; if (xpAct != null) { results.AddRange(InternalFindMissing(xpAct.ResultsCollection)); if (!string.IsNullOrEmpty(xpAct.SourceString)) { results.Add(xpAct.SourceString); } } } else if (activityType == typeof(DsfSqlBulkInsertActivity)) { var sbiAct = activity as DsfSqlBulkInsertActivity; if (sbiAct != null) { results.AddRange(InternalFindMissing(sbiAct.InputMappings)); if (!string.IsNullOrEmpty(sbiAct.Result)) { results.Add(sbiAct.Result); } } } else if (activityType == typeof(DsfFindRecordsMultipleCriteriaActivity)) { DsfFindRecordsMultipleCriteriaActivity frmAct = activity as DsfFindRecordsMultipleCriteriaActivity; if (frmAct != null) { results.AddRange(InternalFindMissing(frmAct.ResultsCollection)); if (!string.IsNullOrEmpty(frmAct.FieldsToSearch)) { results.Add(frmAct.FieldsToSearch); } if (!string.IsNullOrEmpty(frmAct.Result)) { results.Add(frmAct.Result); } } } var act = activity as DsfNativeActivity <string>; if (act != null) { if (!string.IsNullOrEmpty(act.OnErrorVariable)) { results.Add(act.OnErrorVariable); } if (!string.IsNullOrEmpty(act.OnErrorWorkflow)) { results.Add(act.OnErrorWorkflow); } } return(results); }