示例#1
0
 /// <summary>
 ///  Initializes a new instance of the <see cref="X12Group{T}"/> class.
 /// </summary>
 /// <param name="header">The group header.</param>
 public X12Group(S_GS header)
     : base(header, (gs, i) => new S_GE
 {
     D_97_1 = i.ToString(),
     D_28_2 = gs.D_28_6
 }, Separators.DefaultX12())
 {
 }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="X12Interchange"/> class.
 /// </summary>
 /// <param name="header">The interchange header.</param>
 public X12Interchange(S_ISA header)
     : base(header, (gs, i) => new S_IEA
 {
     D_405_1 = i.ToString(),
     D_709_2 = header.D_709_13
 }, Separators.DefaultX12())
 {
     if (header == null)
     {
         throw new Exception("ISA header is null.");
     }
 }
示例#3
0
        public void TestGenerateWithSegmentSeparatorLf()
        {
            // ARRANGE
            const string sample      = "EdiFabric.Tests.Edi.X12_810_00204_SegmentSeparatorLF.txt";
            var          interchange = TestHelper.GenerateX12 <M_810>(sample);

            // ACT
            var defaultSeparators = Separators.DefaultX12();
            var newSeparators     = new Separators('\n',
                                                   '>', defaultSeparators.DataElement, defaultSeparators.RepetitionDataElement, null);
            var ediSegments = interchange.GenerateEdi(newSeparators);

            // ASSERT
            Assert.AreEqual(TestHelper.AsString(sample, false), TestHelper.AsString(ediSegments, null));
        }
示例#4
0
        public void TestGenerateWithDuplicateSeparator()
        {
            // ARRANGE
            const string sample      = "EdiFabric.Tests.Edi.X12_810_00204_RepetitionSeparator.txt";
            var          interchange = TestHelper.GenerateX12 <Rules.Rep.X12002040810.M_810>(sample, "EdiFabric.Rules.Rep");

            // ACT
            var defaultSeparators = Separators.DefaultX12();
            var newSeparators     = new Separators(defaultSeparators.Segment,
                                                   '>', defaultSeparators.DataElement, '>', null);
            var ediSegments = interchange.GenerateEdi(newSeparators);

            // ASSERT
            Assert.AreEqual(TestHelper.AsString(sample), TestHelper.AsString(ediSegments, Environment.NewLine));
        }
示例#5
0
        /// <summary>
        /// Generates a collection of EDI segments from the header, the items and the trailer.
        /// ComponentDataElement separator (ISA 16) and RepetitionDataElement separator (ISA 11)
        /// are discarded if set in the ISA header. Their values are retrieved from the EDI separators.
        /// </summary>
        /// <param name="separators">The EDI separators.</param>
        /// <returns>The collection of EDI segments.</returns>
        public override IEnumerable <string> GenerateEdi(Separators separators = null)
        {
            var result            = new List <string>();
            var currentSeparators = separators ?? Separators.DefaultX12();

            Header.D_701_16 = currentSeparators.ComponentDataElement.ToString();
            if (Header.D_726_11 != "U")
            {
                Header.D_726_11 = currentSeparators.RepetitionDataElement.ToString();
            }

            result.AddRange(ToEdi(Header, currentSeparators));
            foreach (var item in Items)
            {
                result.AddRange(item.GenerateEdi(currentSeparators));
            }
            result.AddRange(ToEdi(Trailer, currentSeparators));

            return(result);
        }