private static void AssignNotJson(IDSFDataObject dataObject, IServiceTestOutput output, string variable, string value) { if (!DataListUtil.IsValueRecordset(output.Variable)) { dataObject.Environment.Assign(variable, value, 0); } }
static void UpdateToPending(IServiceTestOutput serviceTestOutput) { if (serviceTestOutput?.Result != null) { serviceTestOutput.Result.RunTestResult = RunResult.TestPending; } else { if (serviceTestOutput != null) { serviceTestOutput.Result = new TestRunResult { RunTestResult = RunResult.TestPending }; } } }
void AddBlankRowToRecordset(IServiceTestOutput dlItem, IList <IScalar> columns, int indexToInsertAt, int indexNum, IDataListModel dataList) { IList <IScalar> recsetCols = columns.Distinct(Scalar.Comparer).ToList(); string colName = null; foreach (var col in recsetCols.Distinct(new ScalarNameComparer())) { if (string.IsNullOrEmpty(colName) || !colName.Equals(col.Name)) { var recSetName = DataListUtil.ExtractRecordsetNameFromValue(dlItem.Variable); var varName = string.Concat(recSetName, @"(", indexNum, @").", col.Name); var serviceTestOutput = new ServiceTestOutput(varName, string.Empty, string.Empty, string.Empty); serviceTestOutput.AddNewAction = () => AddRow(serviceTestOutput, dataList); Outputs.Insert(indexToInsertAt + 1, serviceTestOutput); indexToInsertAt++; } colName = col.Name; } }
private static ServiceTestOutput GetTestOutput(ServiceTestStep testStep, IServiceTestOutput serviceTestOutput) { var variable = serviceTestOutput.Variable ?? ""; var value = serviceTestOutput.Value ?? ""; var to = serviceTestOutput.To ?? ""; var from = serviceTestOutput.From ?? ""; var testOutput = new ServiceTestOutput(variable, value, from, to) { AddStepOutputRow = testStep.AddNewOutput, AssertOp = serviceTestOutput.AssertOp ?? "=", HasOptionsForValue = serviceTestOutput.HasOptionsForValue, OptionsForValue = serviceTestOutput.OptionsForValue ?? new List <string>(), Result = serviceTestOutput.Result ?? new TestRunResult { RunTestResult = RunResult.TestPending } }; return(testOutput); }
public void AddRow(IServiceTestOutput itemToAdd, IDataListModel dataList) { if (itemToAdd != null && DataListUtil.IsValueRecordset(itemToAdd.Variable)) { var recordsetNameFromValue = DataListUtil.ExtractRecordsetNameFromValue(itemToAdd.Variable); var recordset = dataList.ShapeRecordSets.FirstOrDefault(set => set.Name == recordsetNameFromValue); if (recordset == null) { return; } var recsetCols = new List <IScalar>(); foreach (var column in recordset.Columns) { var cols = column.Value.Where(scalar => scalar.IODirection == enDev2ColumnArgumentDirection.Output || scalar.IODirection == enDev2ColumnArgumentDirection.Both); recsetCols.AddRange(cols); } var numberOfRows = Outputs.Where(c => DataListUtil.ExtractRecordsetNameFromValue(c.Variable) == recordsetNameFromValue); IEnumerable <IServiceTestOutput> dataListItems = numberOfRows as IServiceTestOutput[] ?? numberOfRows.ToArray(); var lastItem = dataListItems.Last(); var indexToInsertAt = Outputs.IndexOf(lastItem); var indexString = DataListUtil.ExtractIndexRegionFromRecordset(lastItem.Variable); var indexNum = Convert.ToInt32(indexString) + 1; var lastRow = dataListItems.Where(c => DataListUtil.ExtractIndexRegionFromRecordset(c.Variable) == indexString); var addRow = false; foreach (var item in lastRow) { if (item.Value != string.Empty) { addRow = true; } } if (addRow) { AddBlankRowToRecordset(itemToAdd, recsetCols, indexToInsertAt, indexNum, dataList); } } }
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 void DispatchDebugState(IDSFDataObject dataObject, IDev2MethodInfo dev2MethodInfo, int index, IServiceTestOutput serviceTestOutput) { var start = DateTime.Now; if (dev2MethodInfo.IsObject) { var jContainer = JToken.Parse(serviceTestOutput.Value) as JContainer ?? serviceTestOutput.Value.DeserializeToObject(); if (!string.IsNullOrEmpty(serviceTestOutput.Variable)) { dataObject.Environment.AddToJsonObjects(serviceTestOutput.Variable, jContainer); } } else { dataObject.Environment.Assign(serviceTestOutput.Variable, serviceTestOutput.Value, 0); } dev2MethodInfo.MethodResult = serviceTestOutput.Value; MethodsToRun[index].MethodResult = serviceTestOutput.Value; DispatchDebugStateForMethod(MethodsToRun[index], dataObject, 0, true, start); }
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); }