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