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); }
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); }