public void Equals_Given_ResultCollection_With_Same_Items_IsEqual() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var resultCol = new List <Unlimited.Applications.BusinessDesignStudio.Activities.XPathDTO>(); resultCol.Add ( new Unlimited.Applications.BusinessDesignStudio.Activities.XPathDTO { } ); var xPath = new DsfXPathActivity() { UniqueID = uniqueId, ResultsCollection = resultCol }; var xPath1 = new DsfXPathActivity() { UniqueID = uniqueId, ResultsCollection = resultCol }; //---------------Assert Precondition---------------- Assert.IsNotNull(xPath); //---------------Execute Test ---------------------- var @equals = xPath.Equals(xPath1); //---------------Test Result ----------------------- Assert.IsTrue(@equals); }
protected override void BuildDataList() { BuildShapeAndTestData(); scenarioContext.TryGetValue("xmlData", out string xmlData); var xPath = new DsfXPathActivity { SourceString = xmlData }; TestStartNode = new FlowStep { Action = xPath }; scenarioContext.TryGetValue("xpathDtos", out List <Tuple <string, string> > xpathDtos); var row = 1; foreach (var variable in xpathDtos) { xPath.ResultsCollection.Add(new XPathDTO(variable.Item1, variable.Item2, row, true)); row++; } scenarioContext.Add("activity", xPath); }
protected override void BuildDataList() { BuildShapeAndTestData(); string xmlData; ScenarioContext.Current.TryGetValue("xmlData", out xmlData); var xPath = new DsfXPathActivity { SourceString = xmlData }; TestStartNode = new FlowStep { Action = xPath }; List<Tuple<string, string>> xpathDtos; ScenarioContext.Current.TryGetValue("xpathDtos", out xpathDtos); int row = 1; foreach(var variable in xpathDtos) { xPath.ResultsCollection.Add(new XPathDTO(variable.Item1, variable.Item2, row, true)); row++; } ScenarioContext.Current.Add("activity", xPath); }
public void RecsetWithStarExpectedXPaths_InsideForEach_ShouldRespect_UpdateValueForRecordsetIndex() { _resultsCollection.Add(new XPathDTO("[[recset1(*).field1]]", "//type/method/@signature", 1)); const string dataSplitPreDataList = "<ADL><xmlData/><recset1><field1/></recset1><recset2><field2/></recset2><OutVar1/><OutVar2/><OutVar3/><OutVar4/><OutVar5/></ADL>"; var act = new DsfXPathActivity { SourceString = Source, ResultsCollection = _resultsCollection }; CurrentDl = dataSplitPreDataList; TestData = "<root>" + dataSplitPreDataList + "</root>"; if (CurrentDl == null) { CurrentDl = TestData; } var dataObject = new DsfDataObject(CurrentDl, ExecutionId) { ServerID = Guid.NewGuid(), ExecutingUser = User, IsDebug = false, EnvironmentID = new Guid(), IsRemoteInvokeOverridden = false, DataList = new StringBuilder(CurrentDl) }; if (!string.IsNullOrEmpty(TestData)) { ExecutionEnvironmentUtils.UpdateEnvironmentFromXmlPayload(dataObject, new StringBuilder(TestData), CurrentDl, 0); } List <string> expected = new List <string> { "void(object)", "void(object)", "void(Dev2.DynamicServices.IDynamicServiceObject, object)", "void(CommandLine.Text.HelpText)", "string()", "Unlimited.Applications.WebServer.Responses.CommunicationResponseWriter(object, string, string)" }; string error; for (int i = 1; i < 4; i++) { act.Execute(dataObject, i); } List <string> actual = RetrieveAllRecordSetFieldValues(dataObject.Environment, "recset1", "field1", out error); Assert.IsNotNull(actual); Assert.AreEqual(3, actual.Count); Assert.AreEqual("Unlimited.Applications.WebServer.Responses.CommunicationResponseWriter(object, string, string)", actual[0]); Assert.AreEqual("Unlimited.Applications.WebServer.Responses.CommunicationResponseWriter(object, string, string)", actual[1]); Assert.AreEqual("Unlimited.Applications.WebServer.Responses.CommunicationResponseWriter(object, string, string)", actual[2]); }
public void DsfXPathActivity_UpdateForEachOutputs_NullUpdates_DoesNothing() { //------------Setup for test-------------------------- _resultsCollection.Add(new XPathDTO("[[recset1(*).field1]]", "//x/a/text()", 1)); var act = new DsfXPathActivity { ResultsCollection = _resultsCollection, SourceString = "xml" }; act.UpdateForEachOutputs(null, null); //------------Assert Results------------------------- Assert.AreEqual("[[recset1(*).field1]]", act.ResultsCollection[0].OutputVariable); Assert.AreEqual("//x/a/text()", act.ResultsCollection[0].XPath); Assert.AreEqual("xml", act.SourceString); }
public void GetOutputs_Called_ShouldReturnListWithResultValueInIt() { //------------Setup for test-------------------------- _resultsCollection.Add(new XPathDTO("[[recset1(*).field1]]", "//x/a/text()", 1)); var act = new DsfXPathActivity { ResultsCollection = _resultsCollection, SourceString = "xml" }; //------------Execute Test--------------------------- var outputs = act.GetOutputs(); //------------Assert Results------------------------- Assert.AreEqual(1, outputs.Count); Assert.AreEqual("[[recset1(*).field1]]", outputs[0]); }
public void Equals_Given_DifferentxPathTools_Is_Not_Equal() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var xPathActivity = new DsfXPathActivity(); var xPathActivity1 = new DsfXPathActivity(); //---------------Assert Precondition---------------- Assert.IsNotNull(xPathActivity); //---------------Execute Test ---------------------- var @equals = xPathActivity.Equals(xPathActivity1); //---------------Test Result ----------------------- Assert.IsFalse(@equals); }
public void DsfXPathActivity_GetForEachOutputs_WhenHasResult_ReturnsOutputList() { //------------Setup for test-------------------------- _resultsCollection.Add(new XPathDTO("[[recset1(*).field1]]", "//x/a/text()", 1)); var act = new DsfXPathActivity { ResultsCollection = _resultsCollection, SourceString = "xml" }; //------------Execute Test--------------------------- var dsfForEachItems = act.GetForEachOutputs(); //------------Assert Results------------------------- Assert.AreEqual(1, dsfForEachItems.Count); Assert.AreEqual("[[recset1(*).field1]]", dsfForEachItems[0].Name); Assert.AreEqual("[[recset1(*).field1]]", dsfForEachItems[0].Value); }
public void DsfXPathActivity_GetState_ReturnsStateVariable() { //---------------Set up test pack------------------- _resultsCollection.Add(new XPathDTO("[[recset1(*).field1]]", "//x/a/text()", 1)); //------------Setup for test-------------------------- var act = new DsfXPathActivity { SourceString = "xml", ResultsCollection = _resultsCollection }; //------------Execute Test--------------------------- var stateItems = act.GetState(); Assert.AreEqual(2, stateItems.Count()); var expectedResults = new[] { new StateVariable { Name = "SourceString", Type = StateVariable.StateType.Input, Value = "xml" }, new StateVariable { Name = "ResultsCollection", Type = StateVariable.StateType.Output, Value = ActivityHelper.GetSerializedStateValueFromCollection(_resultsCollection) } }; 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 DsfXPathActivity_UpdateForEachOutputs_1Updates_UpdateCommandResult() { //------------Setup for test-------------------------- _resultsCollection.Add(new XPathDTO("[[recset1(*).field1]]", "//x/a/text()", 1)); var act = new DsfXPathActivity { ResultsCollection = _resultsCollection, SourceString = "xml" }; var tuple1 = new Tuple <string, string>("[[recset1(*).field1]]", "Test"); //------------Execute Test--------------------------- act.UpdateForEachOutputs(new List <Tuple <string, string> > { tuple1 }, null); //------------Assert Results------------------------- Assert.AreEqual("Test", act.ResultsCollection[0].OutputVariable); Assert.AreEqual("//x/a/text()", act.ResultsCollection[0].XPath); Assert.AreEqual("xml", act.SourceString); }
public void Equals_Given_Same_SourceString_Value_Different_Casing_IsNotEqual() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var xPath = new DsfXPathActivity() { UniqueID = uniqueId, SourceString = "A" }; var xPath1 = new DsfXPathActivity() { UniqueID = uniqueId, SourceString = "a" }; //---------------Assert Precondition---------------- Assert.IsNotNull(xPath); //---------------Execute Test ---------------------- var @equals = xPath.Equals(xPath1); //---------------Test Result ----------------------- Assert.IsFalse(@equals); }
public void UniqueIDEquals_EmptyXpathTools_AreEqual() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var xPathActivity = new DsfXPathActivity() { UniqueID = uniqueId }; var xPathActivity1 = new DsfXPathActivity() { UniqueID = uniqueId }; //---------------Assert Precondition---------------- Assert.IsNotNull(xPathActivity); //---------------Execute Test ---------------------- var @equals = xPathActivity.Equals(xPathActivity1); //---------------Test Result ----------------------- Assert.IsTrue(@equals); }
public void GetActivityFieldsOf_DsfXPathActivity_ExpectedAllFindMissingFieldsToBeReturned() { var act = new DsfXPathActivity { ResultsCollection = new List <XPathDTO> { new XPathDTO("[[outputVar1]]", "//the/path1", 1), new XPathDTO("[[outputVar2]]", "//the/path2", 2) }, OnErrorVariable = "[[onErr]]", SourceString = "[[SourceString]]" }; var fac = new Dev2FindMissingStrategyFactory(); var strategy = fac.CreateFindMissingStrategy(enFindMissingType.MixedActivity); var actual = strategy.GetActivityFields(act); var expected = new List <string> { "[[outputVar1]]", "//the/path1", "[[outputVar2]]", "//the/path2", "[[SourceString]]", "[[onErr]]" }; CollectionAssert.AreEqual(expected, actual); }
/// <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); }
public void DsfXPathActivity_GetForEachOutputs_WhenHasResult_ReturnsOutputList() { //------------Setup for test-------------------------- _resultsCollection.Add(new XPathDTO("[[recset1(*).field1]]", "//x/a/text()", 1)); var act = new DsfXPathActivity { ResultsCollection = _resultsCollection, SourceString = "xml" }; //------------Execute Test--------------------------- var dsfForEachItems = act.GetForEachOutputs(); //------------Assert Results------------------------- Assert.AreEqual(1, dsfForEachItems.Count); Assert.AreEqual("[[recset1(*).field1]]", dsfForEachItems[0].Name); Assert.AreEqual("[[recset1(*).field1]]", dsfForEachItems[0].Value); }
public void DsfXPathActivity_UpdateForEachOutputs_1Updates_UpdateCommandResult() { //------------Setup for test-------------------------- _resultsCollection.Add(new XPathDTO("[[recset1(*).field1]]", "//x/a/text()", 1)); var act = new DsfXPathActivity { ResultsCollection = _resultsCollection, SourceString = "xml" }; var tuple1 = new Tuple<string, string>("[[recset1(*).field1]]", "Test"); //------------Execute Test--------------------------- act.UpdateForEachOutputs(new List<Tuple<string, string>> { tuple1 }); //------------Assert Results------------------------- Assert.AreEqual("Test", act.ResultsCollection[0].OutputVariable); Assert.AreEqual("//x/a/text()", act.ResultsCollection[0].XPath); Assert.AreEqual("xml", act.SourceString); }
public void DsfXPathActivity_UpdateForEachOutputs_NullUpdates_DoesNothing() { //------------Setup for test-------------------------- _resultsCollection.Add(new XPathDTO("[[recset1(*).field1]]", "//x/a/text()", 1)); var act = new DsfXPathActivity { ResultsCollection = _resultsCollection, SourceString = "xml" }; act.UpdateForEachOutputs(null); //------------Assert Results------------------------- Assert.AreEqual("[[recset1(*).field1]]", act.ResultsCollection[0].OutputVariable); Assert.AreEqual("//x/a/text()", act.ResultsCollection[0].XPath); Assert.AreEqual("xml", act.SourceString); }