public void TestCrLf() { // ARRANGE const string sample = "EdiWeave.UnitTests.X12.Edi.X12_810_00204_CRLF.txt"; var ediStream = CommonHelper.LoadStream(sample); var expected = CommonHelper.LoadString(sample); List <EdiItem> ediItems; Separators separators; // ACT using (var ediReader = new X12Reader(ediStream, "EdiWeave.Rules.X12002040")) { ediItems = ediReader.ReadToEnd().ToList(); separators = ediReader.Separators; } var actual = X12Helper.Generate(ediItems, separators, "\n"); // ASSERT Assert.IsNotNull(ediItems); Assert.IsNotNull(ediItems.OfType <ISA>().SingleOrDefault()); Assert.IsNotNull(ediItems.OfType <GS>().SingleOrDefault()); Assert.IsNotNull(ediItems.OfType <TS810>().SingleOrDefault()); Assert.IsNotNull(ediItems.OfType <GE>().SingleOrDefault()); Assert.IsNotNull(ediItems.OfType <IEA>().SingleOrDefault()); Assert.IsNull(ediItems.OfType <ErrorContext>().SingleOrDefault()); Assert.AreEqual(expected, actual); }
public void TestMultipleInterchange() { // ARRANGE const string sample = "EdiWeave.UnitTests.X12.Edi.X12_810_00204_MultipleInterchanges.txt"; var ediStream = CommonHelper.LoadStream(sample); var expected = CommonHelper.LoadString(sample); var ediItems = new List <EdiItem>(); // ACT var actual = ""; using (var ediReader = new X12Reader(ediStream, "EdiWeave.Rules.X12002040")) { while (ediReader.Read()) { if (ediReader.Item is ISA && ediItems.Any()) { actual = actual + X12Helper.Generate(ediItems, null, Environment.NewLine); ediItems.Clear(); } ediItems.Add(ediReader.Item); } actual = actual + X12Helper.Generate(ediItems, ediReader.Separators, Environment.NewLine); } // ASSERT Assert.AreEqual(expected, actual); }
public void TestNoValidationAttributes() { // ARRANGE const string sample = "EdiWeave.UnitTests.X12.Edi.X12_810_00204.txt"; var ediStream = CommonHelper.LoadStream(sample); var expected = CommonHelper.LoadString(sample); List <EdiItem> ediItems; // ACT using (var ediReader = new X12Reader(ediStream, "EdiWeave.Rules.X12002040.NoValidation")) { ediItems = ediReader.ReadToEnd().ToList(); } var actual = X12Helper.Generate(ediItems, null, Environment.NewLine); // ASSERT Assert.IsNotNull(ediItems); Assert.IsNotNull(ediItems.OfType <ISA>().SingleOrDefault()); Assert.IsNotNull(ediItems.OfType <GS>().SingleOrDefault()); Assert.IsNotNull(ediItems.OfType <TS810NoValidation>().SingleOrDefault()); Assert.IsNotNull(ediItems.OfType <GE>().SingleOrDefault()); Assert.IsNotNull(ediItems.OfType <IEA>().SingleOrDefault()); Assert.IsNull(ediItems.OfType <ErrorContext>().SingleOrDefault()); Assert.AreEqual(expected, actual); }
public void TestLoadingWithDelegate() { // ARRANGE const string sample = "EdiFabric.UnitTests.X12.Edi.X12_810_00204.txt"; var ediStream = CommonHelper.LoadStream(sample); var expected = CommonHelper.LoadString(sample); List <EdiItem> ediItems; // ACT using (var ediReader = new X12Reader(ediStream, AssemblyLoadFactory)) { ediItems = ediReader.ReadToEnd().ToList(); } var actual = X12Helper.Generate(ediItems, null, Environment.NewLine); // ASSERT Assert.IsNotNull(ediItems); Assert.IsNotNull(ediItems.OfType <ISA>().SingleOrDefault()); Assert.IsNotNull(ediItems.OfType <GS>().SingleOrDefault()); Assert.IsNotNull(ediItems.OfType <TS810>().SingleOrDefault()); Assert.IsNotNull(ediItems.OfType <GE>().SingleOrDefault()); Assert.IsNotNull(ediItems.OfType <IEA>().SingleOrDefault()); Assert.IsNull(ediItems.OfType <ErrorContext>().SingleOrDefault()); Assert.AreEqual(expected, actual); }
public void TestBlankRepetition() { // ARRANGE const string sample = "EdiFabric.UnitTests.X12.Edi.X12_810_00204_BlankRepetition.txt"; const string cleanSample = "EdiFabric.UnitTests.X12.Edi.X12_810_00204_BlankRepetitionClean.txt"; var ediStream = CommonHelper.LoadStream(sample); var expected = CommonHelper.LoadString(cleanSample); List <EdiItem> ediItems; Separators separators; // ACT using (var ediReader = new X12Reader(ediStream, "EdiFabric.Rules.X12002040")) { ediItems = ediReader.ReadToEnd().ToList(); separators = ediReader.Separators; } var actual = X12Helper.Generate(ediItems, separators, Environment.NewLine); // ASSERT Assert.IsNotNull(ediItems); Assert.IsNotNull(ediItems.OfType <ISA>().SingleOrDefault()); Assert.IsNotNull(ediItems.OfType <GS>().SingleOrDefault()); Assert.IsNotNull(ediItems.OfType <TS810>().SingleOrDefault()); Assert.IsNotNull(ediItems.OfType <GE>().SingleOrDefault()); Assert.IsNotNull(ediItems.OfType <IEA>().SingleOrDefault()); Assert.IsNull(ediItems.OfType <ErrorContext>().SingleOrDefault()); Assert.AreEqual(expected, actual); }
public void TestBom() { // ARRANGE const string sample = "EdiWeave.UnitTests.X12.Edi.X12_810_00204_BOM.txt"; var ediStream = CommonHelper.LoadStream(sample); var expected = CommonHelper.LoadString(sample); List <EdiItem> ediItems; // ACT using (var ediReader = new X12Reader(ediStream, "EdiWeave.Rules.X12002040")) { ediItems = ediReader.ReadToEnd().ToList(); } var actual = X12Helper.Generate(ediItems, null, Environment.NewLine); // ASSERT Assert.AreEqual(expected, actual); }
public void TestDuplicateSeparator() { // ARRANGE const string sample = "EdiFabric.UnitTests.X12.Edi.X12_810_00204_RepetitionSeparator.txt"; var ediStream = CommonHelper.LoadStream(sample); var expected = CommonHelper.LoadString(sample); List <EdiItem> ediItems; Separators separators; // ACT using (var ediReader = new X12Reader(ediStream, "EdiFabric.Rules.X12002040.Rep")) { ediItems = ediReader.ReadToEnd().ToList(); separators = ediReader.Separators; } var actual = X12Helper.Generate(ediItems, separators, Environment.NewLine); // ASSERT Assert.AreEqual(expected, actual); }
public void Test5010Hl() { // ARRANGE const string sample = "EdiFabric.UnitTests.Hipaa.Edi.Hipaa_837P_00501_HL.txt"; var ediStream = CommonHelper.LoadStream(sample); var expected = CommonHelper.LoadString(sample); List <EdiItem> ediItems; // ACT using (var ediReader = new X12Reader(ediStream, HipaaFactory)) { ediItems = ediReader.ReadToEnd().ToList(); } var actual = X12Helper.Generate(ediItems, null, Environment.NewLine); // ASSERT Assert.IsNotNull(ediItems); Assert.IsNotNull(ediItems.OfType <ISA>().SingleOrDefault()); Assert.IsNotNull(ediItems.OfType <GS>().SingleOrDefault()); Assert.AreEqual(expected, actual); }
public void Test5010Lfnm1Lisa() { // ARRANGE const string sample = "EdiWeave.UnitTests.Hipaa.Edi.Hipaa_837P_00501_LF.txt"; var ediStream = CommonHelper.LoadStream(sample); var expected = CommonHelper.LoadString(sample); List <EdiItem> ediItems; Separators separators; // ACT using (var ediReader = new X12Reader(ediStream, HipaaFactory)) { ediItems = ediReader.ReadToEnd().ToList(); separators = ediReader.Separators; } var actual = X12Helper.Generate(ediItems, separators, ""); // ASSERT Assert.IsNotNull(ediItems); Assert.IsNotNull(ediItems.OfType <ISA>().SingleOrDefault()); Assert.IsNotNull(ediItems.OfType <GS>().SingleOrDefault()); Assert.AreEqual(expected, actual); }
public void TestMultipleMessages() { // ARRANGE const string sample = "EdiFabric.UnitTests.X12.Edi.X12_810_00204_MultipleMessages.txt"; var ediStream = CommonHelper.LoadStream(sample); var expected = CommonHelper.LoadString(sample); List <EdiItem> ediItems; // ACT using (var ediReader = new X12Reader(ediStream, "EdiFabric.Rules.X12002040")) { ediItems = ediReader.ReadToEnd().ToList(); } var actual = X12Helper.Generate(ediItems, null, Environment.NewLine); // ASSERT Assert.IsTrue(ediItems.OfType <TS810>().Count() == 2); Assert.IsTrue(ediItems.OfType <ISA>().Count() == 1); Assert.IsTrue(ediItems.OfType <GS>().Count() == 1); Assert.IsTrue(ediItems.OfType <GE>().Count() == 1); Assert.IsTrue(ediItems.OfType <IEA>().Count() == 1); Assert.IsNull(ediItems.OfType <ErrorContext>().SingleOrDefault()); Assert.AreEqual(expected, actual); }