public void TestParseEdifactWithInterchangeRead() { // ARRANGE const string sample = "EdiFabric.Tests.Edi.Edifact_INVOIC_D00A_MultipleInterchange.txt"; var ediItems = new List <object>(); // ACT using (var ediReader = EdifactReader.Create(TestHelper.Load(sample))) { while (ediReader.Read()) { ediItems.Add(ediReader.Item); if (!(ediReader.Item is S_UNZ)) { continue; } // ASSERT Assert.IsNotNull(ediItems.OfType <S_UNB>().SingleOrDefault()); Assert.IsNull(ediItems.OfType <S_UNG>().SingleOrDefault()); Assert.IsNotNull(ediItems.OfType <M_INVOIC>().SingleOrDefault()); Assert.IsNull(ediItems.OfType <S_UNE>().SingleOrDefault()); Assert.IsNotNull(ediItems.OfType <S_UNZ>().SingleOrDefault()); Assert.IsNull(ediItems.OfType <ParsingException>().SingleOrDefault()); ediItems.Clear(); } } }
public static List <EdiMessage <S_UNB, S_UNG> > ParseEdifactMultiple(string sample, Encoding encoding = null, string rulesAssemblyName = null, string rulesNameSpacePrefix = null) { using (var ediReader = EdifactReader.Create(Load(sample), encoding, rulesAssemblyName, rulesNameSpacePrefix) ) { return(ediReader.ReadAllMessages().ToList()); } }
public static EdiMessage <S_UNB, S_UNG> ParseEdifact(string sample, Encoding encoding = null, string rulesAssemblyName = null, string rulesNameSpacePrefix = null) { using (var ediReader = EdifactReader.Create(Load(sample), encoding, rulesAssemblyName, rulesNameSpacePrefix) ) { return(ediReader.ReadMessage() ? ediReader.Message : null); } }
public static IEnumerable <object> ParseEdifact(string sample, Encoding encoding = null, string rulesAssembly = null, string rulesNameSpacePrefix = null) { using ( var ediReader = EdifactReader.Create(Load(sample), rulesAssembly ?? "EdiFabric.Rules", rulesNameSpacePrefix ?? "EdiFabric.Rules", encoding ?? Encoding.Default)) { return(ediReader.ReadToEnd().ToList()); } }
public static IEnumerable <object> ParseEdifact(string sample, Encoding encoding = null, string rulesAssemblyName = null, string rulesNameSpacePrefix = null) { using ( var ediReader = EdifactReader.Create(Load(sample), new ReaderSettings { Encoding = encoding, RulesAssemblyName = rulesAssemblyName, RulesNamespacePrefix = rulesNameSpacePrefix })) { return(ediReader.ReadToEnd().ToList()); } }
public void TestParseEdifactWithValidAndInvalidMessageRead() { // ARRANGE const string sample = "EdiFabric.Tests.Edi.Edifact_INVOIC_D00A_ValidAndInvalidMessage.txt"; // ACT using (var ediReader = EdifactReader.Create(TestHelper.Load(sample))) { var ediItems = ediReader.ReadToEnd().ToList(); // ASSERT Assert.IsNotNull(ediItems.OfType <S_UNB>().SingleOrDefault()); Assert.IsNull(ediItems.OfType <S_UNG>().SingleOrDefault()); Assert.IsNotNull(ediItems.OfType <M_INVOIC>().SingleOrDefault()); Assert.IsNull(ediItems.OfType <S_UNE>().SingleOrDefault()); Assert.IsNotNull(ediItems.OfType <S_UNZ>().SingleOrDefault()); Assert.IsNotNull(ediItems.OfType <ParsingException>().SingleOrDefault()); } }
public void TestParseEdifactWithMissingInterchangeTrailer() { // ARRANGE const string sample = "EdiFabric.Tests.Edi.Edifact_INVOIC_D00A_MissingInterchangeTrailer.txt"; var ediItems = new List <object>(); // ACT using (var ediReader = EdifactReader.Create(TestHelper.Load(sample))) { while (ediReader.Read()) { ediItems.Add(ediReader.Item); } } // ASSERT Assert.IsTrue(ediItems.OfType <S_UNB>().Count() == 2); Assert.IsNull(ediItems.OfType <S_UNG>().SingleOrDefault()); Assert.IsTrue(ediItems.OfType <M_INVOIC>().Count() == 2); Assert.IsNull(ediItems.OfType <S_UNE>().SingleOrDefault()); Assert.IsNotNull(ediItems.OfType <S_UNZ>().SingleOrDefault()); Assert.IsNull(ediItems.OfType <ParsingException>().SingleOrDefault()); }