Пример #1
0
        public void X12_204_Test()
        {
            var grammar = EdiGrammar.NewX12();

            grammar.SetAdvice(
                segmentNameDelimiter: '*',
                dataElementSeparator: '*',
                componentDataElementSeparator: ':',
                segmentTerminator: '~',
                releaseCharacter: null,
                reserved: null,
                decimalMark: '.');

            string text = string.Empty;

            using (var filestream = Helpers.GetResourceStream("204-MGCTLYST-SAMPLE.EDI"))
                using (var reader = new StreamReader(filestream))
                    text = reader.ReadToEnd();

            var stream = new MemoryStream(Encoding.UTF8.GetBytes(text.Replace('\n', '~')));

            var segmentCount = 0;

            using (var ediReader = new EdiTextReader(new StreamReader(stream), grammar)) {
                while (ediReader.Read())
                {
                    if (ediReader.TokenType == EdiToken.SegmentName)
                    {
                        segmentCount++;
                    }
                }
            }
            Assert.Equal(42, segmentCount);
        }
Пример #2
0
        public void X12_204_Test()
        {
            var grammar = EdiGrammar.NewX12();

            grammar.SetAdvice(
                segmentNameDelimiter: '*',
                dataElementSeparator: '*',
                componentDataElementSeparator: ':',
                segmentTerminator: '~',
                releaseCharacter: null,
                reserved: null,
                decimalMark: '.');

            var    workingDirectory = Directory.GetCurrentDirectory();
            string text             = File.ReadAllText(workingDirectory + @"\Samples\204-MGCTLYST-SAMPLE.EDI");
            var    stream           = new MemoryStream(Encoding.UTF8.GetBytes(text.Replace('\n', '~')));

            var segmentCount = 0;

            using (var ediReader = new EdiTextReader(new StreamReader(stream), grammar)) {
                while (ediReader.Read())
                {
                    if (ediReader.TokenType == EdiToken.SegmentName)
                    {
                        segmentCount++;
                    }
                }
            }
            Assert.Equal(42, segmentCount);
        }
Пример #3
0
        public void ReaderTest() {
            var msgCount = 0;
            var grammar = EdiGrammar.NewTradacoms();

            using (var ediReader = new EdiTextReader(new StreamReader(Helpers.GetResourceStream("tradacoms.order9.edi")), grammar)) {
                while (ediReader.Read()) {
                    if (ediReader.IsStartMessage) {
                        msgCount++;
                    }
                }
            }
            Assert.Equal(4, msgCount);
        }
Пример #4
0
        public void ReaderTest()
        {
            var msgCount = 0;
            var grammar  = EdiGrammar.NewTradacoms();

            using (var ediReader = new EdiTextReader(new StreamReader(Helpers.GetResourceStream("tradacoms.order9.edi")), grammar)) {
                while (ediReader.Read())
                {
                    if (ediReader.IsStartMessage)
                    {
                        msgCount++;
                    }
                }
            }
            Assert.Equal(4, msgCount);
        }
Пример #5
0
        public void ReaderStrips_Z_Padding_Test()
        {
            var grammar = EdiGrammar.NewEdiFact();

            using (var ediReader = new EdiTextReader(new StreamReader(Helpers.StreamFromString("DTM+ZZZ'DTM+ZZ1'")), grammar)) {
                ediReader.Read();
                ediReader.Read();
                ediReader.Read();
                ediReader.Read(); // move to component
                var number = ediReader.ReadAsInt32();
                Assert.Null(number);
                ediReader.Read();
                ediReader.Read();
                ediReader.Read();
                ediReader.Read(); // move to component;
                var number2 = ediReader.ReadAsInt32();
                Assert.Equal(1, number2.Value);
            }
        }
Пример #6
0
 public void ReaderStrips_Z_Padding_Test() {
     var grammar = EdiGrammar.NewEdiFact();
     using (var ediReader = new EdiTextReader(new StreamReader(Helpers.StreamFromString("DTM+ZZZ'DTM+ZZ1'")), grammar)) {
         ediReader.Read();
         ediReader.Read();
         ediReader.Read();
         ediReader.Read(); // move to component
         var number = ediReader.ReadAsInt32();
         Assert.Null(number);
         ediReader.Read();
         ediReader.Read();
         ediReader.Read();
         ediReader.Read(); // move to component;
         var number2 = ediReader.ReadAsInt32();
         Assert.Equal(1, number2.Value);
     }
 }
Пример #7
0
 public void X12_204_Test() {
     var grammar = EdiGrammar.NewX12();
     grammar.SetAdvice(
         segmentNameDelimiter: '*', 
         dataElementSeparator: '*', 
         componentDataElementSeparator: ':', 
         segmentTerminator: '~', 
         releaseCharacter: null, 
         reserved: null, 
         decimalMark: '.');
     
     var workingDirectory = Directory.GetCurrentDirectory();
     string text = File.ReadAllText(workingDirectory + @"\Samples\204-MGCTLYST-SAMPLE.EDI");
     var stream = new MemoryStream(Encoding.UTF8.GetBytes(text.Replace('\n', '~')));
     
     var segmentCount = 0;
     using (var ediReader = new EdiTextReader(new StreamReader(stream), grammar)) {
         while (ediReader.Read()) {
             if (ediReader.TokenType == EdiToken.SegmentName) {
                 segmentCount++;
             }
         }
     }
     Assert.Equal(42, segmentCount);
 }