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

            var interchange = default(Interchange_ORDRSP);

            using (var stream = Helpers.GetResourceStream("edifact.ORDRSP-formatted.edi")) {
                interchange = new EdiSerializer().Deserialize <Interchange_ORDRSP>(new StreamReader(stream), grammar);
            }

            Assert.Equal(2, interchange.Message.IMD_List.Count);
            Assert.NotNull(interchange.Message.IMD_Other);

            Assert.Null(interchange.Message.IMD_List[0].FieldA);
            Assert.Equal("Z01", interchange.Message.IMD_List[0].FieldB);
            Assert.Null(interchange.Message.IMD_List[0].FieldC);

            Assert.Null(interchange.Message.IMD_List[1].FieldA);
            Assert.Equal("Z10", interchange.Message.IMD_List[1].FieldB);
            Assert.Null(interchange.Message.IMD_List[1].FieldC);

            Assert.Null(interchange.Message.IMD_Other.FieldA);
            Assert.Equal("Z14", interchange.Message.IMD_Other.FieldB);
            Assert.Equal("Z07", interchange.Message.IMD_Other.FieldC);
        }
Пример #2
0
        public void SegmentGroups_WithSingleSegment_ShouldEscape()
        {
            var grammar     = EdiGrammar.NewEdiFact();
            var interchange = default(EdiFact_Issue149_SegmentGroups);

            using (var stream = Helpers.GetResourceStream("edifact.Issue149.SegmentGroups.edi")) {
                interchange = new EdiSerializer().Deserialize <EdiFact_Issue149_SegmentGroups>(new StreamReader(stream), grammar);
            }
            Assert.NotNull(interchange);
            Assert.NotNull(interchange.Message);
            Assert.NotNull(interchange.Message.SG15);
            Assert.Equal("ZZZ", interchange.Message.SG15.AJT1);
            Assert.Equal("35", interchange.Message.SG15.AJT2);
            Assert.NotNull(interchange.Message.SG25);
            Assert.Single(interchange.Message.SG25.SG26);
            Assert.Equal("1", interchange.Message.SG25.SG26[0].PAI1);
            Assert.Equal("1", interchange.Message.SG25.SG26[0].PAI2);
            Assert.Equal("1", interchange.Message.SG25.SG26[0].PAI3);
            Assert.NotNull(interchange.Message.SG25.SG26[0].MOA);
            Assert.Equal("ZZZ", interchange.Message.SG25.SG26[0].MOA.MOA1);
            Assert.Equal(9, interchange.Message.SG25.SG26[0].MOA.MOA2);
            Assert.Equal("XXX", interchange.Message.SG25.SG26[0].MOA.MOA3);
            Assert.Single(interchange.Message.SG25.SG26[0].References);
            Assert.Equal("AAA", interchange.Message.SG25.SG26[0].References[0].RFF1);
            Assert.Equal("X", interchange.Message.SG25.SG26[0].References[0].RFF2);
            Assert.Equal("4", interchange.Message.SG25.TAX1);
            Assert.Equal("D", interchange.Message.UNS1);
        }
Пример #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var grammar = new EDI_X12Grammar()
            {
                ComponentDataElementSeparator = new[] { '>' },
                DataElementSeparator          = new[] { '*' },
                DecimalMark               = null,
                ReleaseCharacter          = null,
                Reserved                  = new char[0],
                SegmentTerminator         = '~',
                ServiceStringAdviceTag    = null,
                InterchangeHeaderTag      = "ISA",
                FunctionalGroupHeaderTag  = "GS",
                MessageHeaderTag          = "ST",
                MessageTrailerTag         = "SE",
                FunctionalGroupTrailerTag = "GE",
                InterchangeTrailerTag     = "IEA",
            };

            using (var stream = new StreamReader("C:\\Users\\ccuts\\Documents\\CSharp_Scripts\\hcFinance\\fake835_0.edi")) {
                interchange = new EdiSerializer().Deserialize <Interchange>(stream, grammar);
            }
        }
Пример #4
0
        public static IEnumerable <DataEntity> ReadEDI <T>(string raw, Query query, Reflector r, IEdiGrammar grammar)
        {
            var n = default(T);

            using (TextReader sr = new StringReader(raw)) { n = new EdiSerializer().Deserialize <T>(sr, grammar); }
            return(r.ToDataEntities(new[] { n }, query.RootEntity));
        }
Пример #5
0
        public void EdiFact_01_Segmenents_Only_Multi_Message_Test()
        {
            var grammar     = EdiGrammar.NewEdiFact();
            var interchange = default(Models.EdiFact01_Segments.Interchange_Multi_Message);

            using (var stream = Helpers.GetResourceStream("edifact.01.multi-message.edi")) {
                interchange = new EdiSerializer().Deserialize <Models.EdiFact01_Segments.Interchange_Multi_Message>(new StreamReader(stream), grammar);
            }

            var unbSegment = interchange.Header;

            //Test Interchange de-serialization
            Assert.Equal("UNOC", unbSegment.SyntaxIdentifier);
            Assert.Equal(3, unbSegment.SyntaxVersion);
            Assert.Equal("1234567891123", unbSegment.SenderId);
            Assert.Equal("14", unbSegment.PartnerIDCodeQualifier);
            Assert.Equal("7080005059275", unbSegment.RecipientId);
            Assert.Equal("14", unbSegment.ParterIDCode);
            Assert.Equal("SPOTMARKED", unbSegment.RoutingAddress);
            Assert.Equal(new DateTime(2012, 10, 10, 11, 4, 0), unbSegment.DateOfPreparation);
            Assert.Equal("HBQ001", unbSegment.ControlRef);

            foreach (var message in interchange.Message)
            {
                AssertQuote2Message(message);
            }

            var unz = interchange.Footer;

            Assert.Equal(2, unz.TrailerControlCount);
            Assert.Equal("20101000064507", unz.TrailerControlReference);
        }
Пример #6
0
 public void EscapeCharactersTest() {
     var grammar = EdiGrammar.NewTradacoms();
     var interchange = default(Interchange);
     using (var stream = Helpers.GetResourceStream("tradacoms.utilitybill.escape.edi")) {
         interchange = new EdiSerializer().Deserialize<Interchange>(new StreamReader(stream), grammar);
     }
     Assert.Equal("GEORGE'S FRIED CHIKEN + SONS. Could be the best chicken yet?", interchange.Head.ClientName);
 }
Пример #7
0
 public void DeserializeTest() {
     var grammar = EdiGrammar.NewTradacoms();
     var interchange = default(Interchange);
     using (var stream = Helpers.GetResourceStream("tradacoms.utilitybill.edi")) {
         interchange = new EdiSerializer().Deserialize<Interchange>(new StreamReader(stream), grammar);
     }
     Assert.Equal(1, interchange.Invoices.Count);
 }
Пример #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            var    grammar = EdiGrammar.NewX12();
            string file    = @"C:\Users\dell\Desktop\Stage\New Text Document2.txt";

            var x12_856 = new EdiSerializer().Deserialize <AdvanceShipNotice_856>(new StreamReader(file), grammar);

            //MessageBox.Show(x12_856.Groups[0].Orders[0].HierarchicalLevel1[0].Addresses[0].AddressCode);
        }
Пример #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            var grammar = EdiGrammar.NewX12();

            string file    = @"C:\Users\dell\Desktop\Stage\New Text Document.txt";
            var    x12_850 = new EdiSerializer().Deserialize <PurchaseOrder_850>(new StreamReader(file), grammar);

            MessageBox.Show(x12_850.Date.ToString());
        }
Пример #10
0
        public void DeserializingMessage_without_Interchange()
        {
            var grammar = EdiGrammar.NewEdiFact();
            var message = default(Message_D95B);

            using (var stream = Helpers.GetResourceStream("edifact.D95B.Issue137.EDI")) {
                message = new EdiSerializer().Deserialize <Message_D95B>(new StreamReader(stream), grammar);
            }
            Assert.NotNull(message);
        }
Пример #11
0
        public void EscapeCharactersTest()
        {
            var grammar     = EdiGrammar.NewTradacoms();
            var interchange = default(Interchange);

            using (var stream = Helpers.GetResourceStream("tradacoms.utilitybill.escape.edi")) {
                interchange = new EdiSerializer().Deserialize <Interchange>(new StreamReader(stream), grammar);
            }
            Assert.Equal("GEORGE'S FRIED CHIKEN + SONS. Could be the best chicken yet?", interchange.Head.ClientName);
        }
Пример #12
0
        public void DeserializeTest()
        {
            var grammar     = EdiGrammar.NewTradacoms();
            var interchange = default(Interchange);

            using (var stream = Helpers.GetResourceStream("tradacoms.utilitybill.edi")) {
                interchange = new EdiSerializer().Deserialize <Interchange>(new StreamReader(stream), grammar);
            }
            Assert.Single(interchange.Invoices);
        }
Пример #13
0
        public void EdiTextReader_NewLine_Terminator_CardridgeReturn_ShouldbeIgnored()
        {
            var getInput = new Func <string, StringBuilder>((terminator) => {
                var input = new StringBuilder();
                input.Append($"UNB+UNOA:1+5011408000007:14+5999999999952:14+180525:2030+2216+PASSWORD+IFCSUM{terminator}");
                input.Append($"UNH+1+IFCSUM:D:01B:UN:EAN003{terminator}");
                input.Append($"BGM+610+1000505549+9{terminator}");
                input.Append($"DTM+137:20180525:102{terminator}");
                input.Append($"DTM+11:20180525:102{terminator}");
                input.Append($"CNT+10:5{terminator}");
                input.Append($"CNT+7:25.784:KG{terminator}");
                input.Append($"NAD+CZ+5011408000007.::9+UK2.{terminator}");
                input.Append($"NAD+CA+5999999999950::9{terminator}");
                input.Append($"TDT+20++10:SEA{terminator}");
                input.Append($"CNI+1+311447177::I{terminator}");
                input.Append($"DTM+2:201805290000:203{terminator}");
                input.Append($"CNT+2:64:PA{terminator}");
                input.Append($"CNT+11:1:PA{terminator}");
                input.Append($"CNT+7:8.269:KG{terminator}");
                input.Append($"TSR+3+++11{terminator}");
                input.Append($"NAD+DP+PC+1919990312{terminator}");
                input.Append($"RFF+DQ:5000706244{terminator}");
                input.Append($"RFF+CR:TUESDAY 29TH MAY{terminator}");
                input.Append($"GID+1+:350114081527920321:1:9+1:3600530124848:PK:9{terminator}");
                input.Append($"PIA+1+B0918306:::91{terminator}");
                input.Append($"FTX+AAA+++MAYB NAIL ForeverStrong 06 DeepRed 12{terminator}");
                input.Append($"MEA+AAE+UCO:4+UN:3{terminator}");
                input.Append($"GID+2+:350114081527920321:1:9+1:3600530521845:PK:9{terminator}");
                input.Append($"PIA+1+B1297005:::91{terminator}");
                input.Append($"FTX+AAA+++MAYB Found. Dream Satin Liquid Sand 30{terminator}");
                input.Append($"MEA+AAE+UCO:4+UN:3{terminator}");
                input.Append($"UNT+787+1{terminator}");
                input.Append($"UNZ+1+2216{terminator}");
                return(input);
            });
            var grammar = EdiGrammar.NewEdiFact();

            grammar.SetAdvice(new[] { ':', '+', '.', '?', ' ', '\r' });
            var interchange = default(EDIFact_D01B_IFCSUM);

            using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(getInput("\r\n").ToString()))) {
                interchange = new EdiSerializer().Deserialize <EDIFact_D01B_IFCSUM>(new StreamReader(stream), grammar);
            }
            Assert.Equal(2, interchange.Messages[0].Consignments[0].Goods.Count);
            grammar.SetAdvice(new[] { ':', '+', '.', '?', ' ', '\'' });
            using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(getInput("'\r\n").ToString()))) {
                interchange = new EdiSerializer().Deserialize <EDIFact_D01B_IFCSUM>(new StreamReader(stream), grammar);
            }
            Assert.Equal(2, interchange.Messages[0].Consignments[0].Goods.Count);
            //var output = new StringBuilder();
            //using (var writer = new EdiTextWriter(new StringWriter(output), grammar)) {
            //    new EdiSerializer().Serialize(writer, interchange);
            //}
            //Assert.Equal(input.ToString(), output.ToString());
        }
Пример #14
0
        public void X12_DTM_Should_not_be_empty()
        {
            var grammar     = EdiGrammar.NewX12();
            var interchange = default(PurchaseOrder_850);

            using (var stream = Helpers.GetResourceStream("x12.850.issue135.edi")) {
                interchange = new EdiSerializer().Deserialize <PurchaseOrder_850>(new StreamReader(stream), grammar);
            }
            Assert.NotNull(interchange.Groups[0].Orders[0].Items[0].DeliveryRequestedDate);
            Assert.NotNull(interchange.Groups[0].Orders[0].Items[0].ShipNoLaterDate);
        }
Пример #15
0
        public void SegmentGroup_Close_logic_Should_Iterate_Over_Parents()
        {
            var grammar     = EdiGrammar.NewEdiFact();
            var interchange = default(EDIFact_D01B_IFCSUM);

            using (var stream = Helpers.GetResourceStream("edifact.D01B.IFCSUM.EDI")) {
                interchange = new EdiSerializer().Deserialize <EDIFact_D01B_IFCSUM>(new StreamReader(stream), grammar);
            }

            Assert.Equal(2, interchange.Messages[0].Consignments[0].Goods.Count);
        }
Пример #16
0
        public void SerializeTest()
        {
            var grammar     = EdiGrammar.NewEdiFact();
            var interchange = default(Models.EdiFact01.Interchange);

            using (var stream = Helpers.GetResourceStream("edifact.01.edi")) {
                interchange = new EdiSerializer().Deserialize <Models.EdiFact01.Interchange>(new StreamReader(stream), grammar);
            }


            var expected =
                #region ...edi text output...
                @"UNA:+.? '
UNB+UNOC:3+1234567891123:14:+7080005059275:14:SPOTMARKED+101012:1104+HBQ001++++1'
UNH+1+QUOTES:D:96A:UN:EDIEL2+S'
BGM+310+2010101900026812+9+AB'
DTM+137:201010191104:203'
DTM+163:201010192300:203'
DTM+164:201010202300:203'
DTM+:1:805'
CUX+2:SEK'
NAD+FR+1234567891123::9'
NAD+DO+7080005059275::9'
LOC+105+SE1::SM'
LIN+1++1420:::SM'
DTM+324:201010192300201010200000:013'
PRI+CAL:-2100:'
RNG+4+1:-0.1'
PRI+CAL:21000:'
RNG+4+1:-0.1'
LIN+2++1420:::SM'
DTM+324:201010200000201010200100:013'
PRI+CAL:-2100:'
RNG+4+1:0'
PRI+CAL:21000:'
RNG+4+1:0'
LIN+3++1420:::SM'
DTM+324:201010200100201010200200:013'
PRI+CAL:-2100:'
RNG+4+1:0'
PRI+CAL:21000:'
UNS+S'
UNT+158+1'
UNZ+1+20101000064507'
";

            #endregion

            var output = new StringBuilder();
            using (var writer = new EdiTextWriter(new StringWriter(output), grammar)) {
                new EdiSerializer().Serialize(writer, interchange);
            }
            Assert.Equal(expected, output.ToString());
        }
Пример #17
0
        public void X12_832_PriceSalesCatalogs()
        {
            var grammar     = EdiGrammar.NewX12();
            var interchange = default(X12_832_PriceScalesCatalog);

            using (var stream = Helpers.GetResourceStream("x12.832.edi")) {
                interchange = new EdiSerializer().Deserialize <X12_832_PriceScalesCatalog>(new StreamReader(stream), grammar);
            }
            Assert.Equal(2, interchange.ItemDetails.Count);
            Assert.Equal(3, interchange.ItemDetails[0].Descriptions.Count);
            Assert.Equal('S', interchange.ItemDetails[0].Descriptions[0].ItemDescriptionType);
        }
Пример #18
0
        public void X12_Stack_Empty_InvalidOp_Exception()
        {
            var grammar = EdiGrammar.NewX12();

            var interchange = default(Interchange_Issue88);

            using (var stream = Helpers.GetResourceStream("x12.Issue88.edi")) {
                interchange = new EdiSerializer().Deserialize <Interchange_Issue88>(new StreamReader(stream), grammar);
            }

            Assert.Equal(1, interchange.TrailerControlNumber);
        }
Пример #19
0
        public void Should_Parse_20_Megabyte_File_02()
        {
            var grammar     = EdiGrammar.NewEdiFact();
            var interchange = default(EdiFact_Issue154_Interchange);

            using (var stream = Helpers.GetBigSampleStream("edifact.Issue154.Perf02.edi")) {
                interchange = new EdiSerializer().Deserialize <EdiFact_Issue154_Interchange>(new StreamReader(stream), grammar);
            }

            //Assert.Equal(78880, interchange.Messages.Count);
            Assert.NotNull(interchange);
        }
Пример #20
0
        public void EDIFact_SegmentGroups_Weird_Group_Behaviour()
        {
            var grammar = EdiGrammar.NewEdiFact();

            var interchange = default(Interchange_Issue98);

            using (var stream = Helpers.GetResourceStream("edifact.Issue98.edi")) {
                interchange = new EdiSerializer().Deserialize <Interchange_Issue98>(new StreamReader(stream), grammar);
            }

            Assert.Equal("3210987654321", interchange.Message.Buyer.PartyIdentifier);
            Assert.Equal(2, interchange.Message.Buyer.References.Count);
        }
Пример #21
0
        public void X12_Grammar_Test()
        {
            var grammar     = EdiGrammar.NewX12();
            var interchange = default(Models.PurchaseOrder_850);

            using (var stream = Helpers.GetResourceStream("x12.850.edi")) {
                interchange = new EdiSerializer().Deserialize <Models.PurchaseOrder_850>(new StreamReader(stream), grammar);
            }
            Assert.Equal(new DateTime(2009, 8, 27, 9, 36, 00), interchange.Date);
            Assert.Equal(new DateTime(2009, 8, 27, 10, 41, 00), interchange.Groups[0].Date);
            Assert.Equal(19.95M, interchange.Groups[0].Orders[0].Items[0].UnitPrice);
            Assert.Equal("126 Any St", interchange.Groups[0].Orders[0].Addresses[0].AddressInformation);
        }
Пример #22
0
        public void EdiFact_ElementList()
        {
            var grammar     = EdiGrammar.NewEdiFact();
            var interchange = default(EdiFact_Issue121_ElementList);

            using (var stream = Helpers.GetResourceStream("edifact.Issue121.ElementList.edi")) {
                interchange = new EdiSerializer().Deserialize <EdiFact_Issue121_ElementList>(new StreamReader(stream), grammar);
            }
            Assert.Equal(3, interchange.Msg.Attributes.Count);
            Assert.Equal(6, interchange.Msg.Attributes[2].Infos.Count);
            Assert.Equal("PRIL", interchange.Msg.Attributes[2].Infos[5].Code);
            Assert.Equal("N", interchange.Msg.Attributes[2].Infos[5].Value);
        }
Пример #23
0
        public void X12_214_Test()
        {
            var grammar     = EdiGrammar.NewX12();
            var interchange = default(Models.Transportation_214);

            using (var stream = Helpers.GetResourceStream("x12.214.edi")) {
                interchange = new EdiSerializer().Deserialize <Models.Transportation_214>(new StreamReader(stream), grammar);
            }
            var message = interchange.Groups[0].Messages[0];

            Assert.Equal(3, message.Places.Count);
            Assert.Equal(1751807, message.ReferenceIdentification);
        }
Пример #24
0
        public void EdiTextReader_NewLine_Terminator_support()
        {
            var grammar = EdiGrammar.NewEdiFact();

            grammar.SetAdvice(new[] { ':', '+', '.', '?', ' ', '\n' });
            var interchange = default(EDIFact_D01B_IFCSUM);

            using (var stream = Helpers.GetResourceStream("edifact.D01B.IFCSUM.NewLines.EDI")) {
                interchange = new EdiSerializer().Deserialize <EDIFact_D01B_IFCSUM>(new StreamReader(stream), grammar);
            }

            Assert.Equal(2, interchange.Messages[0].Consignments[0].Goods.Count);
        }
Пример #25
0
        public void SerializeTest() {
            var grammar = EdiGrammar.NewEdiFact();
            var interchange = default(Models.EdiFact01.Interchange);
            using (var stream = Helpers.GetResourceStream("edifact.01.edi")) {
                interchange = new EdiSerializer().Deserialize<Models.EdiFact01.Interchange>(new StreamReader(stream), grammar);
            }


            var expected =
            #region ...edi text output...
@"UNA:+.? '
UNB+UNOC:3+1234567891123:14:+7080005059275:14:SPOTMARKED+101012:1104+HBQ001++++1'
UNH+1+QUOTES:D:96A:UN:EDIEL2+S'
BGM+310+2010101900026812+9+AB'
DTM+137:201010191104:203'
DTM+163:201010192300:203'
DTM+164:201010202300:203'
DTM+:1:805'
CUX+2:SEK'
NAD+FR+1234567891123::9'
NAD+DO+7080005059275::9'
LOC+105+SE1::SM'
LIN+1++1420:::SM'
DTM+324:201010192300201010200000:013'
PRI+CAL:-2100:'
RNG+4+1:-0.1'
PRI+CAL:21000:'
RNG+4+1:-0.1'
LIN+2++1420:::SM'
DTM+324:201010200000201010200100:013'
PRI+CAL:-2100:'
RNG+4+1:0'
PRI+CAL:21000:'
RNG+4+1:0'
LIN+3++1420:::SM'
DTM+324:201010200100201010200200:013'
PRI+CAL:-2100:'
RNG+4+1:0'
PRI+CAL:21000:'
UNS+S'
UNT+158+1'
UNZ+1+20101000064507'
";
            #endregion

            var output = new StringBuilder();
            using (var writer = new EdiTextWriter(new StringWriter(output), grammar)) {
                new EdiSerializer().Serialize(writer, interchange);
            }
            Assert.Equal(expected, output.ToString());
        }
Пример #26
0
        // GET api/values
        public HttpResponseMessage Get()
        {
            var    grammar = EdiGrammar.NewX12();
            string file    = @"C:\Users\dell\Desktop\New Text Document.txt";

            var x12_856 = new EdiSerializer().Deserialize <AdvanceShipNotice_856>(new StreamReader(file), grammar);

            string jsonResult = JsonConvert.SerializeObject(x12_856);

            File.WriteAllText(@"C:\Users\dell\Desktop\React\src\components\Result.json", jsonResult);

            string json = File.ReadAllText(@"C:\Users\dell\Desktop\React\src\components\Result.json");

            return(Request.CreateResponse(HttpStatusCode.OK, json));
        }
Пример #27
0
        public void Tradacoms_ProductPlanning_SampleTest()
        {
            var grammar = EdiGrammar.NewTradacoms();

            var interchange = default(PPRHDR);

            using (var stream = Helpers.GetResourceStream("tradacoms.productplanning.edi")) {
                interchange = new EdiSerializer().Deserialize <PPRHDR>(new StreamReader(stream), grammar);
            }

            Assert.NotNull(interchange.Detail);
            Assert.Equal(2, interchange.Detail.ProductRows.Count);
            Assert.Equal(4, interchange.Detail.ProductRows[0].PosRows.Count);
            Assert.Equal(3, interchange.Detail.ProductRows[1].PosRows.Count);
        }
Пример #28
0
        public void Should_Serialize_Autogenerated_Counts()
        {
            var grammar     = EdiGrammar.NewTradacoms();
            var interchange = default(Interchange_Issue17);

            using (var stream = Helpers.GetResourceStream("tradacoms.Issue17.autogeneratedvalues.edi")) {
                interchange = new EdiSerializer().Deserialize <Interchange_Issue17>(new StreamReader(stream), grammar);
            }
            Assert.NotNull(interchange);
            string output = null;

            using (var writer = new StringWriter()) {
                new EdiSerializer().Serialize(writer, grammar, interchange);
                output = writer.ToString();
            }
        }
Пример #29
0
        public void X12_810_MandatoryConditions_Test()
        {
            var grammar = EdiGrammar.NewX12();

            var interchange = default(Invoice_810);

            using (var stream = Helpers.GetResourceStream("x12.810.mandatory-conditions.edi")) {
                interchange = new EdiSerializer().Deserialize <Invoice_810>(new StreamReader(stream), grammar);
            }

            Assert.NotNull(interchange.Groups[0].Invoice.TotalOutstandingBalance);
            Assert.NotNull(interchange.Groups[0].Invoice.TotalPaymentsAndRefunds);
            Assert.Equal(5.55M, interchange.Groups[0].Invoice.TotalPaymentsAndRefunds.Value);
            Assert.Equal(3.33M, interchange.Groups[0].Invoice.TotalOutstandingBalance.Value);
            Assert.Equal(6.66M, interchange.Groups[0].Invoice.PriorBalance.Value);
        }
Пример #30
0
        public void X12_214_Trailers_Test()
        {
            var grammar     = EdiGrammar.NewX12();
            var interchange = default(Models.Transportation_214);

            using (var stream = Helpers.GetResourceStream("x12.214.edi")) {
                interchange = new EdiSerializer().Deserialize <Models.Transportation_214>(new StreamReader(stream), grammar);
            }
            var group   = interchange.Groups[0];
            var message = group.Messages[0];

            Assert.Equal(16, message.MessageSegmetsCount);
            Assert.Equal("822650001", message.MessageControlNumber);
            Assert.Equal(1, group.TransactionsCount);
            Assert.Equal(82265, group.GroupTrailerControlNumber);
        }
Пример #31
0
        public void X12_850_Issue27_Test()
        {
            var grammar     = EdiGrammar.NewX12();
            var interchange = default(Models.PurchaseOrder_850);

            using (var stream = Helpers.GetResourceStream("x12.850a.edi")) {
                interchange = new EdiSerializer().Deserialize <Models.PurchaseOrder_850>(new StreamReader(stream), grammar);
            }
            Assert.Equal(new DateTime(2009, 8, 27, 9, 36, 00), interchange.Date);
            Assert.Equal(new DateTime(2009, 8, 27, 10, 41, 00), interchange.Groups[0].Date);
            Assert.Equal(2.53M, interchange.Groups[0].Orders[0].Items[0].UnitPrice);
            Assert.Equal("East Point Drive, Suite 500", interchange.Groups[0].Orders[0].Addresses[0].AddressInformation);
            Assert.Equal(2, interchange.Groups[0].Orders[0].Items[0].MSG.Count());
            Assert.Equal("4.4OZ 100% POLYESTER QUILT", interchange.Groups[0].Orders[0].Items[0].MSG[0].MessageText);
            Assert.Equal("First Quality", interchange.Groups[0].Orders[0].Items[0].MSG[1].MessageText);
        }
Пример #32
0
        public void MSCONSTest()
        {
            if (EdiStructureType.None < EdiStructureType.Segment)
            {
            }
            var grammar     = EdiGrammar.NewEdiFact();
            var interchange = default(MSCONS);

            using (var stream = Helpers.GetResourceStream("mscons.edi")) {
                interchange = new EdiSerializer().Deserialize <MSCONS>(new StreamReader(stream), grammar);

                Assert.NotNull(interchange.ListNachricht.First().Nachrichten_Endsegment);

                //Assert.NotNull(interchange.ListNachricht.First().Absender.CTA.EM);
                //Assert.NotNull(interchange.ListNachricht.First().Absender.CTA.EM.Art);
            }
        }
Пример #33
0
        public void DateTimeFromString_Component_MaxLength_Exceeds_StringLength_Test(string dateText, string output)
        {
            var expected    = DateTime.Parse(output, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);
            var grammar     = EdiGrammar.NewEdiFact();
            var edi         = $@"UNB+UNOC:3+109910000+999999999+171215:1048+00336++AO05Q118ke1'
UNH+00001+AESG:02:001:KV'
DTM+137:{dateText}:102'
UNT+6+00001'
UNZ+1+00336'
";
            var interchange = default(Interchange_Issue95);

            using (var stream = Helpers.StreamFromString(edi)) {
                interchange = new EdiSerializer().Deserialize <Interchange_Issue95>(new StreamReader(stream), grammar);
            }

            Assert.Equal(expected, interchange.Msg.DateTime);
        }
Пример #34
0
 public void X12_Grammar_Test() {
     var grammar = EdiGrammar.NewX12();
     var interchange = default(Models.PurchaseOrder_850);
     using (var stream = Helpers.GetResourceStream("x12.850.edi")) {
         interchange = new EdiSerializer().Deserialize<Models.PurchaseOrder_850>(new StreamReader(stream), grammar);
     }
     Assert.Equal(new DateTime(2009, 8, 27, 9, 36, 00), interchange.Date);
     Assert.Equal(new DateTime(2009, 8, 27, 10, 41, 00), interchange.Groups[0].Date);
     Assert.Equal(19.95M, interchange.Groups[0].Orders[0].Items[0].UnitPrice);
     Assert.Equal("126 Any St", interchange.Groups[0].Orders[0].Addresses[0].AddressInformation);
 }
Пример #35
0
 public void X12_214_Test() {
     var grammar = EdiGrammar.NewX12();
     var interchange = default(Models.Transportation_214);
     using (var stream = Helpers.GetResourceStream("x12.214.edi")) {
         interchange = new EdiSerializer().Deserialize<Models.Transportation_214>(new StreamReader(stream), grammar);
     }
     var message = interchange.Groups[0].Messages[0];
     Assert.Equal(3, message.Places.Count);
     Assert.Equal(1751807, message.ReferenceIdentification);
 }
Пример #36
0
        public void EdiFact_01_Test()
        {
            var grammar = EdiGrammar.NewEdiFact();
            var interchange = default(Models.EdiFact01.Interchange);
            using (var stream = Helpers.GetResourceStream("edifact.01.edi"))
            {
                interchange = new EdiSerializer().Deserialize<Models.EdiFact01.Interchange>(new StreamReader(stream), grammar);
            }

            //Test Interchange de-serialization
            Assert.Equal("UNOC", interchange.SyntaxIdentifier);
            Assert.Equal(3, interchange.SyntaxVersion);
            Assert.Equal("1234567891123", interchange.SenderId);
            Assert.Equal("14", interchange.PartnerIDCodeQualifier);
            Assert.Equal("7080005059275", interchange.RecipientId);
            Assert.Equal("14", interchange.ParterIDCode);
            Assert.Equal("SPOTMARKED", interchange.RoutingAddress);
            Assert.Equal(new DateTime(2012, 10, 10, 11, 4, 0), interchange.DateOfPreparation);
            Assert.Equal("HBQ001", interchange.ControlRef);


            var quote = interchange.QuoteMessage;

            //Test Quote Message Header
            Assert.Equal("1", quote.MessageRef);
            Assert.Equal("QUOTES", quote.MessageType);
            Assert.Equal("D", quote.Version);
            Assert.Equal("96A", quote.ReleaseNumber);
            Assert.Equal("UN", quote.ControllingAgency);
            Assert.Equal("EDIEL2", quote.AssociationAssignedCode);
            Assert.Equal("S", quote.CommonAccessRef);

            Assert.Equal("310", quote.MessageName);
            Assert.Equal("2010101900026812", quote.DocumentNumber);
            Assert.Equal("9", quote.MessageFunction);
            Assert.Equal("AB", quote.ResponseType);

            Assert.NotNull(interchange.QuoteMessage.MessageDate.ID);
            Assert.NotNull(interchange.QuoteMessage.ProcessingStartDate.ID);
            Assert.NotNull(interchange.QuoteMessage.ProcessingEndDate.ID);


            Assert.Equal(new DateTime(2010, 10, 19, 11, 04, 00), quote.MessageDate.DateTime);
            Assert.Equal(new DateTime(2010, 10, 19, 23, 00, 00), quote.ProcessingStartDate.DateTime);
            Assert.Equal(new DateTime(2010, 10, 20, 23, 00, 00), quote.ProcessingEndDate.DateTime);

            Assert.Equal(1, quote.UTCOffset.Hours);

            Assert.Equal("2", quote.CurrencyQualifier);
            Assert.Equal("SEK", quote.ISOCurrency);


            Assert.Equal(2, quote.NAD.Count);
            Assert.Equal("FR", quote.NAD[0].PartyQualifier);
            Assert.Equal("1234567891123", quote.NAD[0].PartyId);
            Assert.Equal("9", quote.NAD[0].ResponsibleAgency);

            Assert.Equal("DO", quote.NAD[1].PartyQualifier);
            Assert.Equal("7080005059275", quote.NAD[1].PartyId);
            Assert.Equal("9", quote.NAD[1].ResponsibleAgency);

            Assert.Equal("105", quote.LocationQualifier);
            Assert.Equal("SE1", quote.LocationId);
            Assert.Equal("SM", quote.LocationResponsibleAgency);

            Assert.Equal("SE1", quote.LocationId);
            Assert.Equal("SM", quote.LocationResponsibleAgency);
            
            var linArray = quote.Lines;
            Assert.Equal(new DateTime(2010, 10, 19, 23, 00, 00), linArray[0].Period.Date.From);
            Assert.Equal(new DateTime(2010, 10, 20, 00, 00, 00), linArray[1].Period.Date.From);
            Assert.Equal(new DateTime(2010, 10, 20, 01, 00, 00), linArray[2].Period.Date.From);
            Assert.All(quote.Lines, i => Assert.Equal(2, i.Prices.Count));
        }
Пример #37
0
 public void X12_850_Issue27_Test() {
     var grammar = EdiGrammar.NewX12();
     var interchange = default(Models.PurchaseOrder_850);
     using (var stream = Helpers.GetResourceStream("x12.850a.edi")) {
         interchange = new EdiSerializer().Deserialize<Models.PurchaseOrder_850>(new StreamReader(stream), grammar);
     }
     Assert.Equal(new DateTime(2009, 8, 27, 9, 36, 00), interchange.Date);
     Assert.Equal(new DateTime(2009, 8, 27, 10, 41, 00), interchange.Groups[0].Date);
     Assert.Equal(2.53M, interchange.Groups[0].Orders[0].Items[0].UnitPrice);
     Assert.Equal("East Point Drive, Suite 500", interchange.Groups[0].Orders[0].Addresses[0].AddressInformation);
     Assert.Equal(2, interchange.Groups[0].Orders[0].Items[0].MSG.Count());
     Assert.Equal("4.4OZ 100% POLYESTER QUILT", interchange.Groups[0].Orders[0].Items[0].MSG[0].MessageText);
     Assert.Equal("First Quality", interchange.Groups[0].Orders[0].Items[0].MSG[1].MessageText);
 }