public void RecordSetSearchPayload_WithParamsConstractor_SetProperty_ExpectSetValue()
        {
            //--------------------Arrange--------------------
            var testIndex   = 0;
            var testPayload = "TestPayload";
            //--------------------Act------------------------
            var recordSetSearchPayload = new RecordSetSearchPayload(testIndex, testPayload);

            //--------------------Assert---------------------
            Assert.AreEqual(testIndex, recordSetSearchPayload.Index);
            Assert.AreEqual(testPayload, recordSetSearchPayload.Payload);
        }
Пример #2
0
        /// <summary>
        /// Checks the validity of the input argument and returns the fields in a list of strings
        /// </summary>
        /// <param name="to">To.</param>
        /// <param name="bdl">The BDL.</param>
        /// <param name="errors">The errors.</param>
        /// <returns></returns>
        public Func <IList <RecordSetSearchPayload> > GenerateInputRange(IRecsetSearch to, IBinaryDataList bdl, out ErrorResultTO errors)
        {
            errors = new ErrorResultTO();
            ErrorResultTO allErrors = new ErrorResultTO();

            Func <IList <RecordSetSearchPayload> > result = () =>
            {
                IList <RecordSetSearchPayload> fieldList = new List <RecordSetSearchPayload>();
                string InputField = to.FieldsToSearch;
                string recSet     = DataListUtil.ExtractRecordsetNameFromValue(DataListUtil.StripLeadingAndTrailingBracketsFromValue(InputField));
                IBinaryDataListEntry bdle;
                string error;

                bdl.TryGetEntry(recSet, out bdle, out error);
                allErrors.AddError(error);

                if (bdle == null)
                {
                    throw new RecordsetNotFoundException("Could not find Recordset [ " + recSet + " ]");
                }

                IList <Dev2Column> realCols = bdle.Columns;
                string[]           tmpCols  = InputField.Replace(" ", "").Split(',');

                // Travis.Frisinger : 09.25.2012
                // we need to adjust the tmpCols to avoid * causing crap with the match

                int loc = 0;

                foreach (string tc in tmpCols)
                {
                    string recset      = DataListUtil.ExtractRecordsetNameFromValue(tc);
                    string field       = DataListUtil.ExtractFieldNameFromValue(tc);
                    string myNewSearch = DataListUtil.AddBracketsToValueIfNotExist(DataListUtil.MakeValueIntoHighLevelRecordset(recset));

                    if (field != string.Empty)
                    {
                        myNewSearch = DataListUtil.MakeValueIntoHighLevelRecordset(recset) + "." + field;
                    }

                    tmpCols[loc] = DataListUtil.AddBracketsToValueIfNotExist(myNewSearch);
                    loc++;
                }

                int  pos   = 0;
                bool found = true;
                int  start;
                Int32.TryParse(to.StartIndex, out start);

                if (start == 0)
                {
                    start = 1;
                }

                while (pos < tmpCols.Length && found)
                {
                    int innerPos;
                    if (IsMatch(tmpCols[pos], recSet, realCols, out innerPos))
                    {
                        for (int i = start; i <= bdle.FetchLastRecordsetIndex(); i++)
                        {
                            IBinaryDataListItem tmp = bdle.TryFetchRecordsetColumnAtIndex(realCols[innerPos].ColumnName, i, out error);
                            if (error != string.Empty)
                            {
                                allErrors.AddError(error);
                            }
                            RecordSetSearchPayload p = new RecordSetSearchPayload {
                                Index = i, Payload = tmp.TheValue
                            };
                            fieldList.Add(p);
                        }
                    }
                    else
                    {
                        if (IsRecorsetWithoutField(tmpCols[pos], recSet))
                        {
                            IIndexIterator ixItr = bdle.FetchRecordsetIndexes();
                            while (ixItr.HasMore())
                            {
                                int next = ixItr.FetchNextIndex();
                                foreach (Dev2Column col in realCols)
                                {
                                    IBinaryDataListItem    tmp = bdle.TryFetchRecordsetColumnAtIndex(col.ColumnName, next, out error);
                                    RecordSetSearchPayload p   = new RecordSetSearchPayload {
                                        Index = next, Payload = tmp.TheValue
                                    };
                                    fieldList.Add(p);
                                }
                            }
                        }
                        else
                        {
                            found = false;
                        }
                    }
                    pos++;
                }

                if (!found)
                {
                    fieldList.Clear();
                }

                return(fieldList);
            };


            return(result);
        }