public static GetResourceStream ( string fileName ) : Stream | ||
fileName | string | |
Résultat | Stream |
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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()); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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(); } }
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); }
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); }
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); }
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); } }
public void X12_SegmentGroups_Nesting_SameSegment() { var grammar = EdiGrammar.NewX12(); var interchange = default(Interchange_Issue91); using (var stream = Helpers.GetResourceStream("x12.Issue91.edi")) { interchange = new EdiSerializer().Deserialize <Interchange_Issue91>(new StreamReader(stream), grammar); } Assert.Equal(2, interchange.Msg.Foos.Count); Assert.Equal("TOM", interchange.Msg.Foos[0].Name); Assert.Equal(2, interchange.Msg.Foos[0].Bars.Count); Assert.Equal(123, interchange.Msg.Foos[0].Bars[0].Amount); Assert.Equal(456, interchange.Msg.Foos[0].Bars[1].Amount); Assert.Equal("TIM", interchange.Msg.Foos[0].Name); Assert.Single(interchange.Msg.Foos[1].Bars); Assert.Equal(125, interchange.Msg.Foos[0].Bars[0].Amount); }
public void X12_EndMessage_Mapping() { var grammar = EdiGrammar.NewX12(); var interchange = default(Interchange_Issue101); using (var stream = Helpers.GetResourceStream("x12.Issue101.edi")) { interchange = new EdiSerializer().Deserialize <Interchange_Issue101>(new StreamReader(stream), grammar); } Assert.NotNull(interchange.Msg.Return); var rtn = interchange.Msg.Return; Assert.Equal("12345", rtn.FormGroupSegment.Id); Assert.NotNull(rtn.FormGroupSegment.DateSegment); Assert.Equal(new DateTime(2018, 5, 25), rtn.FormGroupSegment.DateSegment.Date); Assert.Equal("0012", interchange.Msg.HeaderControl); Assert.Equal(interchange.Msg.HeaderControl, interchange.Msg.TrailerControl); }
public void ReferenceSegment() { var grammar = EdiGrammar.NewEdiFact(); var interchange = default(ORDRSP); using (var stream = Helpers.GetResourceStream("edifact.ORDRSP.edi")) { interchange = new EdiSerializer().Deserialize <ORDRSP>(new StreamReader(stream), grammar); } var nachricht = interchange.ListNachricht[0]; Assert.Equal("ON", nachricht.Referenz_der_Anfrage.Code); Assert.NotNull(nachricht.Referenz_der_Anfrage.Referenz_der_Anfragedatum); Assert.NotNull(nachricht.Absender.CTA); Assert.Equal("Spiderman, Clack", nachricht.Absender.CTA.Kontakt); Assert.Equal("IC", nachricht.Absender.CTA.Funktion); Assert.Null(nachricht.Empfaenger.CTA); Assert.Equal("293", nachricht.Empfaenger.Code); Assert.Equal("990000000000X", nachricht.Empfaenger.ID); Assert.Equal("MR", nachricht.Empfaenger.Qualifier); }
public void Dont_write_segment_if_no_value_is_available_Test() { var grammar = EdiGrammar.NewEdiFact(); var interchange = default(EdiPaiement_Issue139); using (var stream = Helpers.GetResourceStream("edifact.Paiement.Issue139.EDI")) { interchange = new EdiSerializer().Deserialize <EdiPaiement_Issue139>(new StreamReader(stream), grammar); } Assert.NotNull(interchange); Assert.NotEmpty(interchange.GroupesFonctionnels); Assert.NotEmpty(interchange.GroupesFonctionnels[0].Messages); Assert.NotEmpty(interchange.GroupesFonctionnels[0].Messages[0].Intervenants); Assert.Equal(2, interchange.GroupesFonctionnels[0].Messages[0].Intervenants.Count); interchange.GroupesFonctionnels[0].Messages[0].Intervenants[1].Reference = null; var expected = new StringBuilder().AppendLine(@"UNA:+,? '") .AppendLine("UNB+UNOL:3+35044551600023:5:I+7501751:146+191007:1205+20191007120559+++++TDT-PED-IN-DP1501/CVA19+1'") .AppendLine("UNG+INFENT+NON_SECURISE_NON_SIGNE+MULTI_DISTRIBUTION+191007:1205+1+UN+D:00B:PD1501'") .AppendLine("UNH+00001+INFENT:D:00B:UN:PD1501'") .AppendLine("BGM+CVA:71:211+INFENT1905SRL BIC IS RN19100211451'") .AppendLine("DTM+242:20190930:102'") .AppendLine("RFF+AUM:EIC'") .AppendLine("RFF+AUN:TELE?'DECLAR::6.5.7.0'") .AppendLine("RFF+AUO:2017.01.0375'") .AppendLine("NAD+DT+350445516:100:107++SRL BIC IS RN 2018+0001 rue 1+VILLE 1++11111'") .AppendLine("RFF+ACD:CVAE1'") .AppendLine("NAD+FR+35044551600023:100:107++CEC_EDI_PAYE:CABINET D?'EXPERTISE COMPTABLE::::3+0016 ZI de 1?'Idustrie+BLOIS++41000'") .AppendLine("UNT+000100+00001'") .AppendLine("UNE+000001+1'") .AppendLine("UNZ+1+20191007120559'").ToString(); string output = null; using (var writer = new StringWriter()) { new EdiSerializer().Serialize(writer, grammar, interchange); output = writer.ToString(); } Assert.Equal(expected, output); }
public void Serialize_ElementList_WithRanged_Path() { var grammar = EdiGrammar.NewEdiFact(); var interchange = default(EdiFact_Issue170_ElementList); using (var stream = Helpers.GetResourceStream("edifact.Issue170.ElementList.edi")) { interchange = new EdiSerializer().Deserialize <EdiFact_Issue170_ElementList>(new StreamReader(stream), grammar); } var expected = new StringBuilder() .AppendLine("UNA:+.? '") .AppendLine("IFT+1:1+This+is+the first'") .AppendLine("IFT+1:2+And+this is+the seccond'") .AppendLine("IFT+1:3+while+this+should come third'").ToString(); string output = null; using (var writer = new StringWriter()) { new EdiSerializer().Serialize(writer, grammar, interchange); output = writer.ToString(); } Assert.Equal(expected, output); }
public void Serialize_ElementList() { var grammar = EdiGrammar.NewEdiFact(); var interchange = default(EdiFact_Issue121_ElementList_Conditions); using (var stream = Helpers.GetResourceStream("edifact.Issue121.ElementList.Conditions.edi")) { interchange = new EdiSerializer().Deserialize <EdiFact_Issue121_ElementList_Conditions>(new StreamReader(stream), grammar); } var expected = new StringBuilder() .AppendLine("UNA:+.? '") .AppendLine("ATR+NEW+PRIO:N'") .AppendLine("ATR+NEW+TGIC:465+TGNO:716073+TGPC:SVX'") .AppendLine("ATR+NEW+ACCS:A+BGCL:Y+BRDP:KBP+OFFP:TSE+PRIL:N'") .AppendLine("ATR++V'") .AppendLine("LTS+�2'").ToString(); string output = null; using (var writer = new StringWriter()) { new EdiSerializer().Serialize(writer, grammar, interchange); output = writer.ToString(); } Assert.Equal(expected, output); }