Esempio n. 1
0
        void AddBlankRowToRecordset(IServiceTestInput 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 serviceTestInput = new ServiceTestInput(varName, string.Empty);
                    serviceTestInput.AddNewAction = () => AddRow(serviceTestInput, dataList);
                    Inputs.Insert(indexToInsertAt + 1, serviceTestInput);
                    indexToInsertAt++;
                }
                colName = col.Name;
            }
        }
        public IServiceTestModel CreateTest(IResourceModel resourceModel, int testNumber, bool isFromDebug)
        {
            var testModel = new ServiceTestModel(resourceModel.ID)
            {
                TestName          = "Test " + (testNumber == 0 ? 1 : testNumber),
                TestPending       = true,
                Enabled           = true,
                NewTest           = true,
                NoErrorExpected   = true,
                ErrorExpected     = false,
                ErrorContainsText = string.Empty,
                Inputs            = new ObservableCollection <IServiceTestInput>(),
                Outputs           = new ObservableCollection <IServiceTestOutput>(),
            };

            if (!string.IsNullOrEmpty(resourceModel.DataList))
            {
                DataList = new DataListModel();
                DataList.Create(resourceModel.DataList, resourceModel.DataList);
                var inputList  = _dataListConversionUtils.GetInputs(DataList);
                var outputList = _dataListConversionUtils.GetOutputs(DataList);
                testModel.Inputs = inputList.Select(sca =>
                {
                    var serviceTestInput          = new ServiceTestInput(sca.DisplayValue, "");
                    serviceTestInput.AddNewAction = () => testModel.AddRow(serviceTestInput, DataList);
                    return((IServiceTestInput)serviceTestInput);
                }).ToObservableCollection();
                if (!isFromDebug)
                {
                    testModel.Outputs = outputList.Select(sca =>
                    {
                        var serviceTestOutput          = new ServiceTestOutput(sca.DisplayValue, "", "", "");
                        serviceTestOutput.AddNewAction = () => testModel.AddRow(serviceTestOutput, DataList);
                        return((IServiceTestOutput)serviceTestOutput);
                    }).ToObservableCollection();
                }
            }
            testModel.Item = (ServiceTestModel)testModel.Clone();
            return(testModel);
        }