static Dev2DecisionStack SetupTos(IEnumerable <IDev2TOFn> valuecoll) { var val = new Dev2DecisionStack { TheStack = new List <Dev2Decision>() }; var value = valuecoll.Select(a => a as DecisionTO); foreach (var decisionTo in value.Where(a => { return(a != null && !a.IsEmpty()); })) { var dev2Decision = new Dev2Decision { Col1 = decisionTo.MatchValue }; if (!string.IsNullOrEmpty(decisionTo.SearchCriteria)) { dev2Decision.Col2 = decisionTo.SearchCriteria; } dev2Decision.EvaluationFn = DecisionDisplayHelper.GetValue(decisionTo.SearchType); if (decisionTo.IsBetweenCriteriaVisible) { dev2Decision.Col2 = decisionTo.From; dev2Decision.Col3 = decisionTo.To; } if (string.IsNullOrEmpty(dev2Decision.Col3)) { dev2Decision.Col3 = ""; } val.TheStack.Add(dev2Decision); } return(val); }
public void DecisionDisplayHelper_GetValue_ShouldMatchToRsOpHandleTypes() { //------------Setup for test-------------------------- var allOptions = FindRecsetOptions.FindAllDecision(); var allMatched = true; //------------Execute Test--------------------------- foreach (var findRecsetOptionse in allOptions) { var decisionType = DecisionDisplayHelper.GetValue(findRecsetOptionse.HandlesType()); if (decisionType == enDecisionType.Choose) { allMatched = false; Assert.Fail($"{findRecsetOptionse.HandlesType()} not found"); } } //------------Assert Results------------------------- Assert.IsTrue(allMatched); }
public DecisionTO(Dev2Decision a, int ind, Action <DecisionTO> updateDisplayAction, Action <DecisionTO> deleteAction) { UpdateDisplayAction = updateDisplayAction ?? (x => { }); _isInitializing = true; Inserted = false; MatchValue = a.Col1; SearchCriteria = a.Col2; SearchType = DecisionDisplayHelper.GetDisplayValue(a.EvaluationFn); IndexNumber = ind; IsSearchCriteriaEnabled = true; IsSearchCriteriaVisible = true; From = a.Col2; To = a.Col3; IsSearchTypeFocused = false; DeleteAction = deleteAction; IsLast = false; DeleteCommand = new RelayCommand(x => { DeleteAction?.Invoke(this); }, CanDelete); _isInitializing = false; }
string ResolveStarredIndices(IExecutionEnvironment env, string mode, out ErrorResultTO errors) { string fn = DecisionDisplayHelper.GetDisplayValue(EvaluationFn); StringBuilder expandStarredIndices = new StringBuilder(); if (DataListUtil.GetRecordsetIndexType(Col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col3) == enRecordsetIndexType.Star) { var allCol3Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col3, env, out errors, 0); expandStarredIndices.Append(Col1 + " " + fn + " " + Col2 + " AND " + allCol3Values[0]); allCol3Values.RemoveAt(0); foreach (var value in allCol3Values) { expandStarredIndices.Append(" " + mode + " " + Col1 + " " + fn + " " + Col2 + " AND " + value); } return("If " + expandStarredIndices); } if (DataListUtil.GetRecordsetIndexType(Col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col3) != enRecordsetIndexType.Star) { var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors, 0); expandStarredIndices.Append(Col1 + " " + fn + " " + allCol2Values[0] + " AND " + Col3); allCol2Values.RemoveAt(0); foreach (var value in allCol2Values) { expandStarredIndices.Append(" " + mode + " " + Col1 + " " + fn + " " + value + " AND " + Col3); } return("If " + expandStarredIndices); } if (DataListUtil.GetRecordsetIndexType(Col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col3) == enRecordsetIndexType.Star) { var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors, 0); var allCol3Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col3, env, out errors, 0); expandStarredIndices.Append(Col1 + " " + fn + " " + allCol2Values[0] + " AND " + allCol3Values[0]); allCol2Values.RemoveAt(0); allCol3Values.RemoveAt(0); for (var i = 0; i < Math.Max(allCol2Values.Count, allCol3Values.Count); i++) { if (i > allCol2Values.Count) { allCol2Values.Add(null); } if (i > allCol3Values.Count) { allCol3Values.Add(null); } expandStarredIndices.Append(" " + mode + " " + Col1 + " " + fn + " " + allCol2Values[i] + " AND " + allCol3Values[i]); } return("If " + expandStarredIndices); } if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col3) != enRecordsetIndexType.Star) { var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0); expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + Col2 + " AND " + Col3); allCol1Values.RemoveAt(0); foreach (var value in allCol1Values) { expandStarredIndices.Append(" " + mode + " " + value + " " + fn + " " + Col2 + " AND " + Col3); } return("If " + expandStarredIndices); } if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col3) == enRecordsetIndexType.Star) { var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0); var allCol3Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col3, env, out errors, 0); expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + Col2 + " AND " + allCol3Values[0]); allCol1Values.RemoveAt(0); allCol3Values.RemoveAt(0); for (var i = 0; i < Math.Max(allCol1Values.Count, allCol3Values.Count); i++) { if (i > allCol1Values.Count) { allCol1Values.Add(null); } if (i > allCol3Values.Count) { allCol3Values.Add(null); } expandStarredIndices.Append(" " + mode + " " + allCol1Values[i] + " " + fn + " " + Col2 + " AND " + allCol3Values[i]); } return("If " + expandStarredIndices); } if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col3) != enRecordsetIndexType.Star) { var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0); var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors, 0); expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + allCol2Values[0] + " AND " + Col3); allCol1Values.RemoveAt(0); allCol2Values.RemoveAt(0); for (var i = 0; i < Math.Max(allCol1Values.Count, allCol2Values.Count); i++) { if (i > allCol1Values.Count) { allCol1Values.Add(null); } if (i > allCol2Values.Count) { allCol2Values.Add(null); } expandStarredIndices.Append(" " + mode + " " + allCol1Values[i] + " " + fn + " " + allCol2Values[0] + " AND " + Col3); } return("If " + expandStarredIndices); } if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col3) == enRecordsetIndexType.Star) { var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0); var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors, 0); var allCol3Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col3, env, out errors, 0); expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + allCol2Values[0] + " AND " + allCol3Values[0]); allCol1Values.RemoveAt(0); allCol2Values.RemoveAt(0); allCol3Values.RemoveAt(0); for (var i = 0; i < Math.Max(allCol1Values.Count, Math.Max(allCol2Values.Count, allCol3Values.Count)); i++) { if (i > allCol1Values.Count) { allCol1Values.Add(null); } if (i > allCol2Values.Count) { allCol2Values.Add(null); } if (i > allCol3Values.Count) { allCol3Values.Add(null); } expandStarredIndices.Append(" " + mode + " " + allCol1Values[i] + " " + fn + " " + allCol2Values[0] + " AND " + allCol3Values[i]); } return("If " + expandStarredIndices); } errors = new ErrorResultTO(); return(null); }
public string GenerateUserFriendlyModel(IExecutionEnvironment env, Dev2DecisionMode mode, out ErrorResultTO errors) { errors = new ErrorResultTO(); ErrorResultTO allErrors = new ErrorResultTO(); string fn = DecisionDisplayHelper.GetDisplayValue(EvaluationFn); if (PopulatedColumnCount == 0) { return("If " + fn + " "); } if (PopulatedColumnCount == 1) { if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star) { var allValues = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0); allErrors.MergeErrors(errors); StringBuilder expandStarredIndex = new StringBuilder(); expandStarredIndex.Append(allValues[0] + " " + fn); allValues.RemoveAt(0); foreach (var value in allValues) { expandStarredIndex.Append(" " + mode + " " + value + " " + fn); } errors = allErrors; return("If " + expandStarredIndex); } errors = allErrors; return("If " + Col1 + " " + fn + " "); } if (PopulatedColumnCount == 2) { StringBuilder expandStarredIndices = new StringBuilder(); if (DataListUtil.GetRecordsetIndexType(Col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) == enRecordsetIndexType.Star) { var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors, 0); allErrors.MergeErrors(errors); expandStarredIndices.Append(Col1 + " " + fn + " " + allCol2Values[0]); allCol2Values.RemoveAt(0); foreach (var value in allCol2Values) { expandStarredIndices.Append(" " + mode + " " + Col1 + " " + fn + " " + value); } errors = allErrors; return("If " + expandStarredIndices); } if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) != enRecordsetIndexType.Star) { var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0); allErrors.MergeErrors(errors); expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + Col2); allCol1Values.RemoveAt(0); foreach (var value in allCol1Values) { expandStarredIndices.Append(" " + mode + " " + value + " " + fn + " " + Col2); } errors = allErrors; return("If " + expandStarredIndices); } if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) == enRecordsetIndexType.Star || DataListUtil.GetRecordsetIndexType(Col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) != enRecordsetIndexType.Star) { var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0); allErrors.MergeErrors(errors); var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors, 0); allErrors.MergeErrors(errors); expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + allCol2Values[0]); allCol1Values.RemoveAt(0); allCol2Values.RemoveAt(0); for (var i = 0; i < Math.Max(allCol1Values.Count, allCol2Values.Count); i++) { if (i > allCol1Values.Count) { allCol1Values.Add(null); } if (i > allCol2Values.Count) { allCol2Values.Add(null); } try { expandStarredIndices.Append(" " + mode + " " + allCol1Values[i] + " " + fn + " " + allCol2Values[i]); } catch (IndexOutOfRangeException) { errors.AddError("You appear to have recordsets of differnt sizes"); allErrors.MergeErrors(errors); } } errors = allErrors; return("If " + expandStarredIndices); } errors = allErrors; return("If " + Col1 + " " + fn + " " + Col2 + " "); } if (PopulatedColumnCount == 3) { var expandStarredIndices = ResolveStarredIndices(env, mode.ToString(), out errors); allErrors.MergeErrors(errors); if (!string.IsNullOrEmpty(expandStarredIndices)) { errors = allErrors; return(expandStarredIndices); } errors = allErrors; return("If " + Col1 + " " + fn + " " + Col2 + " and " + Col3); } errors = allErrors; return("<< Internal Error Generating Decision Model: Populated Column Count Cannot Exeed 3 >>"); }
public void DecisionDisplayHelper_GetErrorMessage_EnumShouldMatchToErrorMessage() { var errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.Choose); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_Choose, "Decision Choose Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsError); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsError, "Decision IsError Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsNotError); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsNotError, "Decision IsNotError Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsNull); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsNull, "Decision IsNull Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsNotNull); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsNotNull, "Decision IsNotNull Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsNumeric); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsNumeric, "Decision IsNumeric Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsNotNumeric); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsNotNumeric, "Decision IsNotNumeric Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsText); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsText, "Decision IsText Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsNotText); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsNotText, "Decision IsNotText Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsAlphanumeric); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsAlphanumeric, "Decision IsAlphanumeric Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsNotAlphanumeric); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsNotAlphanumeric, "Decision IsNotAlphanumeric Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsXML); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsXML, "Decision IsXML Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsNotXML); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsNotXML, "Decision IsNotXML Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsDate); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsDate, "Decision IsDate Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsNotDate); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsNotDate, "Decision IsNotDate Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsEmail); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsEmail, "Decision IsEmail Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsNotEmail); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsNotEmail, "Decision IsNotEmail Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsRegEx); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsRegEx, "Decision IsRegEx Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.NotRegEx); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_NotRegEx, "Decision NotRegEx Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsEqual); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_Equals, "Decision IsEqual Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsNotEqual); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsNotEqual, "Decision IsNotEqual Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsLessThan); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsLessThan, "Decision IsLessThan Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsLessThanOrEqual); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsLessThanOrEqual, "Decision IsLessThanOrEqual Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsGreaterThan); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsGreaterThan, "Decision IsGreaterThan Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsGreaterThanOrEqual); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsGreaterThanOrEqual, "Decision IsGreaterThanOrEqual Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsContains); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsContains, "Decision IsContains Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.NotContain); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_NotContain, "Decision NotContain Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsEndsWith); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsEndsWith, "Decision IsEndsWith Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.NotEndsWith); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_NotEndsWith, "Decision NotEndsWith Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsStartsWith); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsStartsWith, "Decision IsStartsWith Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.NotStartsWith); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_NotStartsWith, "Decision NotStartsWith Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsBetween); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsBetween, "Decision IsBetween Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.NotBetween); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_NotBetween, "Decision NotBetween Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsBinary); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsBinary, "Decision IsBinary Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsNotBinary); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsNotBinary, "Decision IsNotBinary Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsHex); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsHex, "Decision IsHex Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsNotHex); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsNotHex, "Decision IsNotHex Failure Error Message Wrong."); errorMessage = DecisionDisplayHelper.GetFailureMessage(enDecisionType.IsBase64); Assert.AreEqual(errorMessage, Messages.Test_FailureMessage_IsBase64, "Decision IsBase64 Failure Error Message Wrong."); }
#pragma warning disable S3776, S1541 // Complexity of methods should not be too high string ResolveStarredIndicesForLabel(IExecutionEnvironment env, string mode, out ErrorResultTO errors) #pragma warning restore S3776, S1541 // Complexity of methods should not be too high { var fn = DecisionDisplayHelper.GetDisplayValue(_evaluationFn); var expandStarredIndices = new StringBuilder(); if (DataListUtil.GetRecordsetIndexType(_col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col2) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col3) == enRecordsetIndexType.Star) { var allCol3Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col3, env, out errors, 0); expandStarredIndices.Append(_col1 + " " + fn + " " + _col2 + " AND " + allCol3Values[0]); allCol3Values.RemoveAt(0); foreach (var value in allCol3Values) { expandStarredIndices.Append(" " + mode + " " + _col1 + " " + fn + " " + _col2 + " AND " + value); } return("If " + expandStarredIndices); } if (DataListUtil.GetRecordsetIndexType(_col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col2) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col3) != enRecordsetIndexType.Star) { var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col2, env, out errors, 0); expandStarredIndices.Append(_col1 + " " + fn + " " + allCol2Values[0] + " AND " + _col3); allCol2Values.RemoveAt(0); foreach (var value in allCol2Values) { expandStarredIndices.Append(" " + mode + " " + _col1 + " " + fn + " " + value + " AND " + _col3); } return("If " + expandStarredIndices); } if (DataListUtil.GetRecordsetIndexType(_col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col2) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col3) == enRecordsetIndexType.Star) { var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col2, env, out errors, 0); var allCol3Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col3, env, out errors, 0); expandStarredIndices.Append(_col1 + " " + fn + " " + allCol2Values[0] + " AND " + allCol3Values[0]); allCol2Values.RemoveAt(0); allCol3Values.RemoveAt(0); for (var i = 0; i < Math.Max(allCol2Values.Count, allCol3Values.Count); i++) { if (i > allCol2Values.Count) { allCol2Values.Add(null); } if (i > allCol3Values.Count) { allCol3Values.Add(null); } expandStarredIndices.Append(" " + mode + " " + _col1 + " " + fn + " " + allCol2Values[i] + " AND " + allCol3Values[i]); } return("If " + expandStarredIndices); } if (DataListUtil.GetRecordsetIndexType(_col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col2) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col3) != enRecordsetIndexType.Star) { var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col1, env, out errors, 0); expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + _col2 + " AND " + _col3); allCol1Values.RemoveAt(0); foreach (var value in allCol1Values) { expandStarredIndices.Append(" " + mode + " " + value + " " + fn + " " + _col2 + " AND " + _col3); } return("If " + expandStarredIndices); } if (DataListUtil.GetRecordsetIndexType(_col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col2) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col3) == enRecordsetIndexType.Star) { var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col1, env, out errors, 0); var allCol3Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col3, env, out errors, 0); expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + _col2 + " AND " + allCol3Values[0]); allCol1Values.RemoveAt(0); if (allCol3Values.Count > 0) { allCol3Values.RemoveAt(0); } for (var i = 0; i < Math.Max(allCol1Values.Count, allCol3Values.Count); i++) { if (i > allCol1Values.Count) { allCol1Values.Add(null); } if (i > allCol3Values.Count) { allCol3Values.Add(null); } expandStarredIndices.Append(" " + mode + " " + allCol1Values[i] + " " + fn + " " + _col2 + " AND " + allCol3Values[i]); } return("If " + expandStarredIndices); } if (DataListUtil.GetRecordsetIndexType(_col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col2) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col3) != enRecordsetIndexType.Star) { var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col1, env, out errors, 0); var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col2, env, out errors, 0); expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + allCol2Values[0] + " AND " + _col3); allCol1Values.RemoveAt(0); if (allCol2Values.Count > 0) { allCol2Values.RemoveAt(0); } for (var i = 0; i < Math.Max(allCol1Values.Count, allCol2Values.Count); i++) { if (i > allCol1Values.Count) { allCol1Values.Add(null); } if (i > allCol2Values.Count) { allCol2Values.Add(null); } expandStarredIndices.Append(" " + mode + " " + allCol1Values[i] + " " + fn + " " + allCol2Values[0] + " AND " + _col3); } return("If " + expandStarredIndices); } if (DataListUtil.GetRecordsetIndexType(_col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col2) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col3) == enRecordsetIndexType.Star) { var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col1, env, out errors, 0); var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col2, env, out errors, 0); var allCol3Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col3, env, out errors, 0); expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + allCol2Values[0] + " AND " + allCol3Values[0]); allCol1Values.RemoveAt(0); if (allCol2Values.Count > 0) { allCol2Values.RemoveAt(0); } if (allCol3Values.Count > 0) { allCol3Values.RemoveAt(0); } for (var i = 0; i < Math.Max(allCol1Values.Count, Math.Max(allCol2Values.Count, allCol3Values.Count)); i++) { if (i > allCol1Values.Count) { allCol1Values.Add(null); } if (i > allCol2Values.Count) { allCol2Values.Add(null); } if (i > allCol3Values.Count) { allCol3Values.Add(null); } expandStarredIndices.Append(" " + mode + " " + allCol1Values[i] + " " + fn + " " + allCol2Values[0] + " AND " + allCol3Values[i]); } return("If " + expandStarredIndices); } errors = new ErrorResultTO(); return(null); }
#pragma warning disable S3776, S1541 // Complexity of methods should not be too high public string Generate(out ErrorResultTO errors) #pragma warning restore S3776, S1541 // Complexity of methods should not be too high { errors = new ErrorResultTO(); var fn = DecisionDisplayHelper.GetDisplayValue(_evaluationFn); if (_populatedColumnCount == 0) { return("If " + fn + " "); } var allErrors = new ErrorResultTO(); if (_populatedColumnCount == 1) { if (DataListUtil.GetRecordsetIndexType(_col1) == enRecordsetIndexType.Star) { var allValues = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col1, _env, out errors, 0); if (errors.FetchErrors().Count >= 1) { return("If "); } allErrors.MergeErrors(errors); var expandStarredIndex = new StringBuilder(); expandStarredIndex.Append(allValues[0] + " " + fn); allValues.RemoveAt(0); foreach (var value in allValues) { expandStarredIndex.Append(" " + _mode + " " + value + " " + fn); } errors = allErrors; return("If " + expandStarredIndex); } errors = allErrors; return("If " + _col1 + " " + fn + " "); } if (_populatedColumnCount == 2) { var expandStarredIndices = new StringBuilder(); if (DataListUtil.GetRecordsetIndexType(_col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col2) == enRecordsetIndexType.Star) { var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col2, _env, out errors, 0); if (errors.FetchErrors().Count >= 1) { return("If "); } allErrors.MergeErrors(errors); expandStarredIndices.Append(_col1 + " " + fn + " " + allCol2Values[0]); allCol2Values.RemoveAt(0); foreach (var value in allCol2Values) { expandStarredIndices.Append(" " + _mode + " " + _col1 + " " + fn + " " + value); } errors = allErrors; return("If " + expandStarredIndices); } if (DataListUtil.GetRecordsetIndexType(_col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col2) != enRecordsetIndexType.Star) { var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col1, _env, out errors, 0); if (errors.FetchErrors().Count >= 1) { return("If "); } allErrors.MergeErrors(errors); expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + _col2); allCol1Values.RemoveAt(0); foreach (var value in allCol1Values) { expandStarredIndices.Append(" " + _mode + " " + value + " " + fn + " " + _col2); } errors = allErrors; return("If " + expandStarredIndices); } if (DataListUtil.GetRecordsetIndexType(_col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col2) == enRecordsetIndexType.Star || DataListUtil.GetRecordsetIndexType(_col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(_col2) != enRecordsetIndexType.Star) { var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col1, _env, out errors, 0); if (errors.FetchErrors().Count >= 1) { return("If "); } allErrors.MergeErrors(errors); var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(_col2, _env, out errors, 0); allErrors.MergeErrors(errors); expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + allCol2Values[0]); allCol1Values.RemoveAt(0); if (allCol2Values.Count > 0) { allCol2Values.RemoveAt(0); } AddAllColumns(_mode, errors, allErrors, fn, expandStarredIndices, allCol1Values, allCol2Values); errors = allErrors; return("If " + expandStarredIndices); } errors = allErrors; return("If " + _col1 + " " + fn + " " + _col2 + " "); } if (_populatedColumnCount == 3) { var expandStarredIndices = ResolveStarredIndicesForLabel(_env, _mode.ToString(), out errors); allErrors.MergeErrors(errors); if (!string.IsNullOrEmpty(expandStarredIndices)) { errors = allErrors; return(expandStarredIndices); } errors = allErrors; return("If " + _col1 + " " + fn + " " + _col2 + " and " + _col3); } errors = allErrors; return("<< Internal Error Generating Decision Model: Populated Column Count Cannot Exceed 3 >>"); }
public string GenerateUserFriendlyModel(IExecutionEnvironment env, Dev2DecisionMode mode, out ErrorResultTO errors) { errors = new ErrorResultTO(); var allErrors = new ErrorResultTO(); var fn = DecisionDisplayHelper.GetDisplayValue(EvaluationFn); if (PopulatedColumnCount == 0) { return("If " + fn + " "); } if (PopulatedColumnCount == 1) { if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star) { var allValues = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0); allErrors.MergeErrors(errors); var expandStarredIndex = new StringBuilder(); expandStarredIndex.Append(allValues[0] + " " + fn); allValues.RemoveAt(0); foreach (var value in allValues) { expandStarredIndex.Append(" " + mode + " " + value + " " + fn); } errors = allErrors; return("If " + expandStarredIndex); } errors = allErrors; return("If " + Col1 + " " + fn + " "); } if (PopulatedColumnCount == 2) { var expandStarredIndices = new StringBuilder(); if (DataListUtil.GetRecordsetIndexType(Col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) == enRecordsetIndexType.Star) { var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors, 0); allErrors.MergeErrors(errors); expandStarredIndices.Append(Col1 + " " + fn + " " + allCol2Values[0]); allCol2Values.RemoveAt(0); foreach (var value in allCol2Values) { expandStarredIndices.Append(" " + mode + " " + Col1 + " " + fn + " " + value); } errors = allErrors; return("If " + expandStarredIndices); } if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) != enRecordsetIndexType.Star) { var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0); allErrors.MergeErrors(errors); expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + Col2); allCol1Values.RemoveAt(0); foreach (var value in allCol1Values) { expandStarredIndices.Append(" " + mode + " " + value + " " + fn + " " + Col2); } errors = allErrors; return("If " + expandStarredIndices); } if (DataListUtil.GetRecordsetIndexType(Col1) == enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) == enRecordsetIndexType.Star || DataListUtil.GetRecordsetIndexType(Col1) != enRecordsetIndexType.Star && DataListUtil.GetRecordsetIndexType(Col2) != enRecordsetIndexType.Star) { var allCol1Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col1, env, out errors, 0); allErrors.MergeErrors(errors); var allCol2Values = DataListUtil.GetAllPossibleExpressionsForFunctionOperations(Col2, env, out errors, 0); allErrors.MergeErrors(errors); expandStarredIndices.Append(allCol1Values[0] + " " + fn + " " + allCol2Values[0]); allCol1Values.RemoveAt(0); if (allCol2Values.Count > 0) { allCol2Values.RemoveAt(0); } AddAllColumns(mode, errors, allErrors, fn, expandStarredIndices, allCol1Values, allCol2Values); errors = allErrors; return("If " + expandStarredIndices); } errors = allErrors; return("If " + Col1 + " " + fn + " " + Col2 + " "); } if (PopulatedColumnCount == 3) { var expandStarredIndices = ResolveStarredIndices(env, mode.ToString(), out errors); allErrors.MergeErrors(errors); if (!string.IsNullOrEmpty(expandStarredIndices)) { errors = allErrors; return(expandStarredIndices); } errors = allErrors; return("If " + Col1 + " " + fn + " " + Col2 + " and " + Col3); } errors = allErrors; return("<< Internal Error Generating Decision Model: Populated Column Count Cannot Exceed 3 >>"); }
private static IEnumerable <TestRunResult> GetTestRunResults(IDSFDataObject dataObject, IServiceTestOutput output, Dev2DecisionFactory factory, IDebugState debugState) { if (output == null) { var testResult = new TestRunResult { RunTestResult = RunResult.None }; return(new List <TestRunResult> { testResult }); } if (string.IsNullOrEmpty(output.Variable) && string.IsNullOrEmpty(output.Value)) { var testResult = new TestRunResult { RunTestResult = RunResult.None }; output.Result = testResult; return(new List <TestRunResult> { testResult }); } if (output.Result != null) { output.Result.RunTestResult = RunResult.TestInvalid; } if (string.IsNullOrEmpty(output.Variable)) { var testResult = new TestRunResult { RunTestResult = RunResult.TestInvalid, Message = Messages.Test_NothingToAssert }; output.Result = testResult; if (dataObject.IsDebugMode()) { var debugItemStaticDataParams = new DebugItemServiceTestStaticDataParams(testResult.Message, true); DebugItem itemToAdd = new DebugItem(); itemToAdd.AddRange(debugItemStaticDataParams.GetDebugItemResult()); debugState.AssertResultList.Add(itemToAdd); } return(new List <TestRunResult> { testResult }); } IFindRecsetOptions opt = FindRecsetOptions.FindMatch(output.AssertOp); var decisionType = DecisionDisplayHelper.GetValue(output.AssertOp); var value = new List <DataStorage.WarewolfAtom> { DataStorage.WarewolfAtom.NewDataString(output.Value) }; var from = new List <DataStorage.WarewolfAtom> { DataStorage.WarewolfAtom.NewDataString(output.From) }; var to = new List <DataStorage.WarewolfAtom> { DataStorage.WarewolfAtom.NewDataString(output.To) }; IList <TestRunResult> ret = new List <TestRunResult>(); var iter = new WarewolfListIterator(); var cols1 = dataObject.Environment.EvalAsList(DataListUtil.AddBracketsToValueIfNotExist(output.Variable), 0); var c1 = new WarewolfAtomIterator(cols1); var c2 = new WarewolfAtomIterator(value); var c3 = new WarewolfAtomIterator(@from); if (opt.ArgumentCount > 2) { c2 = new WarewolfAtomIterator(to); } iter.AddVariableToIterateOn(c1); iter.AddVariableToIterateOn(c2); iter.AddVariableToIterateOn(c3); while (iter.HasMoreData()) { var val1 = iter.FetchNextValue(c1); var val2 = iter.FetchNextValue(c2); var val3 = iter.FetchNextValue(c3); var assertResult = factory.FetchDecisionFunction(decisionType).Invoke(new[] { val1, val2, val3 }); var testResult = new TestRunResult(); if (assertResult) { testResult.RunTestResult = RunResult.TestPassed; } else { testResult.RunTestResult = RunResult.TestFailed; var msg = DecisionDisplayHelper.GetFailureMessage(decisionType); var actMsg = string.Format(msg, val2, output.Variable, val1, val3); testResult.Message = new StringBuilder(testResult.Message).AppendLine(actMsg).ToString(); } if (dataObject.IsDebugMode()) { var msg = testResult.Message; if (testResult.RunTestResult == RunResult.TestPassed) { msg = Messages.Test_PassedResult; } var hasError = testResult.RunTestResult == RunResult.TestFailed; var debugItemStaticDataParams = new DebugItemServiceTestStaticDataParams(msg, hasError); DebugItem itemToAdd = new DebugItem(); itemToAdd.AddRange(debugItemStaticDataParams.GetDebugItemResult()); if (debugState.AssertResultList != null) { bool addItem = debugState.AssertResultList.Select(debugItem => debugItem.ResultsList.Where(debugItemResult => debugItemResult.Value == Messages.Test_PassedResult)).All(debugItemResults => !debugItemResults.Any()); if (addItem) { debugState.AssertResultList.Add(itemToAdd); } } } output.Result = testResult; ret.Add(testResult); } return(ret); }
private IEnumerable <TestRunResult> GetTestRunResults(IDSFDataObject dataObject, IServiceTestOutput output, Dev2DecisionFactory factory) { var expressionType = output.AssertOp ?? string.Empty; IFindRecsetOptions opt = FindRecsetOptions.FindMatch(expressionType); var decisionType = DecisionDisplayHelper.GetValue(expressionType); if (decisionType == enDecisionType.IsError) { var hasErrors = dataObject.Environment.AllErrors.Count > 0; var testResult = new TestRunResult(); if (hasErrors) { testResult.RunTestResult = RunResult.TestPassed; } else { testResult.RunTestResult = RunResult.TestFailed; var msg = DecisionDisplayHelper.GetFailureMessage(decisionType); var actMsg = string.Format(msg); testResult.Message = new StringBuilder(testResult.Message).AppendLine(actMsg).ToString(); } return(new[] { testResult }); } if (decisionType == enDecisionType.IsNotError) { var noErrors = dataObject.Environment.AllErrors.Count == 0; var testResult = new TestRunResult(); if (noErrors) { testResult.RunTestResult = RunResult.TestPassed; } else { testResult.RunTestResult = RunResult.TestFailed; var msg = DecisionDisplayHelper.GetFailureMessage(decisionType); var actMsg = string.Format(msg); testResult.Message = new StringBuilder(testResult.Message).AppendLine(actMsg).ToString(); } return(new[] { testResult }); } var value = new List <DataStorage.WarewolfAtom> { DataStorage.WarewolfAtom.NewDataString(output.Value) }; var from = new List <DataStorage.WarewolfAtom> { DataStorage.WarewolfAtom.NewDataString(output.From) }; var to = new List <DataStorage.WarewolfAtom> { DataStorage.WarewolfAtom.NewDataString(output.To) }; IList <TestRunResult> ret = new List <TestRunResult>(); var iter = new WarewolfListIterator(); var variable = DataListUtil.AddBracketsToValueIfNotExist(output.Variable); var cols1 = dataObject.Environment.EvalAsList(variable, 0); var c1 = new WarewolfAtomIterator(cols1); var c2 = new WarewolfAtomIterator(value); var c3 = new WarewolfAtomIterator(to); if (opt.ArgumentCount > 2) { c2 = new WarewolfAtomIterator(from); } iter.AddVariableToIterateOn(c1); iter.AddVariableToIterateOn(c2); iter.AddVariableToIterateOn(c3); while (iter.HasMoreData()) { var val1 = iter.FetchNextValue(c1); var val2 = iter.FetchNextValue(c2); var val3 = iter.FetchNextValue(c3); var assertResult = factory.FetchDecisionFunction(decisionType).Invoke(new[] { val1, val2, val3 }); var testResult = new TestRunResult(); if (assertResult) { testResult.RunTestResult = RunResult.TestPassed; } else { testResult.RunTestResult = RunResult.TestFailed; var msg = DecisionDisplayHelper.GetFailureMessage(decisionType); var actMsg = string.Format(msg, val2, variable, val1, val3); testResult.Message = new StringBuilder(testResult.Message).AppendLine(actMsg).ToString(); } output.Result = testResult; ret.Add(testResult); } return(ret); }