Ejemplo n.º 1
0
        private int AddErrorAndMerge(IDev2MergeOperations mergeOperations, ErrorResultTO allErrors, int pos, string val, string at, string pad)
        {
            if (val != null && at != null && pad != null)
            {
                if (MergeCollection[pos].MergeType == "Index")
                {
                    if (string.IsNullOrEmpty(at))
                    {
                        allErrors.AddError(ErrorResource.BlankUSINGValue);
                    }

                    if (!Int32.TryParse(at, out int atValue) || atValue < 0)
                    {
                        allErrors.AddError(ErrorResource.USINGMustBeARealNumber);
                    }
                    if (pad.Length > 1)
                    {
                        allErrors.AddError(ErrorResource.PADDINGMustBeSingleCharecter);
                    }
                }
                else
                {
                    if (MergeCollection[pos].MergeType == "Chars" && string.IsNullOrEmpty(at))
                    {
                        allErrors.AddError(ErrorResource.BlankUSINGValue);
                    }
                }
                mergeOperations.Merge(val, MergeCollection[pos].MergeType, at, pad, MergeCollection[pos].Alignment);
                pos++;
            }

            return(pos);
        }
 public void Merge_Index_Merge_Left_Padding_Pad_Five_Chars_Expected_Successful_Merge()
 {
     _mergeOperations.Clear();
     _mergeOperations.Merge(@"TestData!!", "Index", "15", "0", "Left");
     Assert.AreEqual("TestData!!00000", _mergeOperations.MergeData.ToString());
 }