From f2bb29c1b2d844ccedfbc8d1ff7fb057ed4ad7ac Mon Sep 17 00:00:00 2001 From: Mark Campbell Date: Thu, 14 Mar 2013 13:12:32 -0400 Subject: [PATCH] Remove all outdated test/unit tests --- test/tc_factory_270.rb | 170 ----------------- test/tc_factory_270interchange.rb | 306 ------------------------------ test/tc_factory_997.rb | 134 ------------- test/tc_parse_270.rb | 98 ---------- test/tc_parse_270interchange.rb | 184 ------------------ test/tc_parse_997.rb | 146 -------------- 6 files changed, 1038 deletions(-) delete mode 100644 test/tc_factory_270.rb delete mode 100644 test/tc_factory_270interchange.rb delete mode 100644 test/tc_factory_997.rb delete mode 100644 test/tc_parse_270.rb delete mode 100644 test/tc_parse_270interchange.rb delete mode 100644 test/tc_parse_997.rb diff --git a/test/tc_factory_270.rb b/test/tc_factory_270.rb deleted file mode 100644 index 920ab12..0000000 --- a/test/tc_factory_270.rb +++ /dev/null @@ -1,170 +0,0 @@ -#-- -# This file is part of the X12Parser library that provides tools to -# manipulate X12 messages using Ruby native syntax. -# -# http://x12parser.rubyforge.org -# -# Copyright (C) 2008 APP Design, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -#++ -# -require 'x12' -require 'test/unit' - -class Test270Factory < Test::Unit::TestCase - - @@p = nil -@@result=<<-EOT -ST*270*1001~ -BHT*0022*13*LNKJNFGRWDLR*20070724*1726~ -HL*1**20*1~ -NM1*PR*2*BIG PAYOR*****PI*CHICAGO BLUES~ -HL*2*1*21*1~ -NM1*1P*1******SV*daw~ -HL*3*2*22*0~ -NM1*IL*1*Doe*Joe~ -DMG*D8*19700725~ -DTP*307*D8*20070724~ -EQ*60~ -SE*12*1001~ -EOT - - @@result.gsub!(/\n/,'') - - def setup - unless @@p - @@p = X12::Parser.new('misc/270.xml') - end - end # setup - - def teardown - # Nothing - end # teardown - - def test_all - @r = @@p.factory('270') - count = 0 - - @r.ST.TransactionSetControlNumber = '1001' - count += 1 - - @r.BHT {|bht| - bht.HierarchicalStructureCode='0022' - bht.TransactionSetPurposeCode='13' - bht.ReferenceIdentification='LNKJNFGRWDLR' - bht.Date='20070724' - bht.Time='1726' - } - count += 1 - - @r.L2000A {|l2000A| - l2000A.HL{|hl| - hl.HierarchicalIdNumber='1' - hl.HierarchicalParentIdNumber='' - hl.HierarchicalChildCode='1' - } - count += 1 - - l2000A.L2100A {|l2100A| - l2100A.NM1 {|nm1| - nm1.EntityIdentifierCode1='PR' - nm1.EntityTypeQualifier='2' - nm1.NameLastOrOrganizationName='BIG PAYOR' - nm1.IdentificationCodeQualifier='PI' - nm1.IdentificationCode='CHICAGO BLUES' - } - count += 1 - } - } - - @r.L2000B {|l2000B| - l2000B.HL{|hl| - hl.HierarchicalIdNumber='2' - hl.HierarchicalParentIdNumber='1' - hl.HierarchicalChildCode='1' - } - count += 1 - - l2000B.L2100B {|l2100B| - l2100B.NM1 {|nm1| - nm1.EntityIdentifierCode1='1P' - nm1.EntityTypeQualifier='1' - nm1.NameLastOrOrganizationName='' - nm1.IdentificationCodeQualifier='SV' - nm1.IdentificationCode='daw' - } - count += 1 - } - } - - @r.L2000C {|l2000C| - l2000C.HL{|hl| - hl.HierarchicalIdNumber='3' - hl.HierarchicalParentIdNumber='2' - hl.HierarchicalChildCode='0' - } - count += 1 - - l2000C.L2100C {|l2100C| - l2100C.NM1 {|nm1| - nm1.EntityIdentifierCode1='IL' - nm1.EntityTypeQualifier='1' - nm1.NameLastOrOrganizationName='Doe' - nm1.NameFirst='Joe' - } - count += 1 - - l2100C.DMG {|dmg| - dmg.DateTimePeriodFormatQualifier='D8' - dmg.DateTimePeriod='19700725' - } - count += 1 - - l2100C.DTP {|dtp| - dtp.DateTimeQualifier='307' - dtp.DateTimePeriodFormatQualifier='D8' - dtp.DateTimePeriod='20070724' - } - count += 1 - - l2100C.L2110C {|l2110C| - l2110C.EQ {|eq| - eq.ServiceTypeCode='60' - } - count += 1 - } - } - } - - count += 1 - @r.SE {|se| - se.NumberOfIncludedSegments = count - se.TransactionSetControlNumber = '1001' - } - - assert_equal(@@result, @r.render) - end # test_all - - def test_timing - start = Time::now - X12::TEST_REPEAT.times do - test_all - end - finish = Time::now - puts sprintf("Factories per second, 270: %.2f, elapsed: %.1f", X12::TEST_REPEAT.to_f/(finish-start), finish-start) - end # test_timing - -end # TestList diff --git a/test/tc_factory_270interchange.rb b/test/tc_factory_270interchange.rb deleted file mode 100644 index 09a1839..0000000 --- a/test/tc_factory_270interchange.rb +++ /dev/null @@ -1,306 +0,0 @@ -#-- -# This file is part of the X12Parser library that provides tools to -# manipulate X12 messages using Ruby native syntax. -# -# http://x12parser.rubyforge.org -# -# Copyright (C) 2008 APP Design, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -#++ -# -require 'x12' -require 'test/unit' - -class Test270FactoryInterchange < Test::Unit::TestCase - - @@p = nil -@@result=<<-EOT -ISA*03*user *01*password *ZZ*0000000Eliginet*ZZ*CHICAGO BLUES*070724*1726*U*00401*230623206*0*T*:~ -GS*HS*0000000Eliginet*CHICAGO BLUES*20070724*1726*000*X*004010X092A1~ -ST*270*0000~ -BHT*0022*13*LNKJNFGRWDLR*20070724*1726~ -HL*1**20*1~ -NM1*PR*2*RED CROSS*****PI*CHICAGO BLUES~ -HL*2*1*21*1~ -NM1*1P*1******SV*daw~ -HL*3*2*22*0~ -NM1*IL*1*LastName*FirstName~ -DMG*D8*19700725~ -DTP*307*D8*20070724~ -EQ*60~ -SE*12*0000~ -ST*270*0001~ -BHT*0022*13*LNKJNFGRWDLR*20070724*1726~ -HL*1**20*1~ -NM1*PR*2*RED CROSS*****PI*CHICAGO BLUES~ -HL*2*1*21*1~ -NM1*1P*1******SV*daw~ -HL*3*2*22*0~ -NM1*IL*1*LastName*FirstName~ -DMG*D8*19700725~ -DTP*307*D8*20070724~ -EQ*60~ -SE*12*0001~ -ST*270*0002~ -BHT*0022*13*LNKJNFGRWDLR*20070724*1726~ -HL*1**20*1~ -NM1*PR*2*RED CROSS*****PI*CHICAGO BLUES~ -HL*2*1*21*1~ -NM1*1P*1******SV*daw~ -HL*3*2*22*0~ -NM1*IL*1*LastName*FirstName~ -DMG*D8*19700725~ -DTP*307*D8*20070724~ -EQ*60~ -SE*12*0002~ -GE*3*000~ -GS*HS*0000000Eliginet*CHICAGO BLUES*20070724*1726*001*X*004010X092A1~ -ST*270*1000~ -BHT*0022*13*LNKJNFGRWDLR*20070724*1726~ -HL*1**20*1~ -NM1*PR*2*RED CROSS*****PI*CHICAGO BLUES~ -HL*2*1*21*1~ -NM1*1P*1******SV*daw~ -HL*3*2*22*0~ -NM1*IL*1*LastName*FirstName~ -DMG*D8*19700725~ -DTP*307*D8*20070724~ -EQ*60~ -SE*12*1000~ -ST*270*1001~ -BHT*0022*13*LNKJNFGRWDLR*20070724*1726~ -HL*1**20*1~ -NM1*PR*2*RED CROSS*****PI*CHICAGO BLUES~ -HL*2*1*21*1~ -NM1*1P*1******SV*daw~ -HL*3*2*22*0~ -NM1*IL*1*LastName*FirstName~ -DMG*D8*19700725~ -DTP*307*D8*20070724~ -EQ*60~ -SE*12*1001~ -GE*2*001~ -GS*HS*0000000Eliginet*CHICAGO BLUES*20070724*1726*002*X*004010X092A1~ -ST*270*2000~ -BHT*0022*13*LNKJNFGRWDLR*20070724*1726~ -HL*1**20*1~ -NM1*PR*2*RED CROSS*****PI*CHICAGO BLUES~ -HL*2*1*21*1~ -NM1*1P*1******SV*daw~ -HL*3*2*22*0~ -NM1*IL*1*LastName*FirstName~ -DMG*D8*19700725~ -DTP*307*D8*20070724~ -EQ*60~ -SE*12*2000~ -GE*1*002~ -IEA*3*230623206~ -EOT - - @@result.gsub!(/\n/,'') - - def setup - unless @@p - @@p = X12::Parser.new('misc/270interchange.xml') - end - end # setup - - def teardown - # Nothing - end # teardown - - def create_270(message, fg_num, mess_num) - transactionSetControlNumber = "#{fg_num}00#{mess_num}" - count = 0 - - message.ST.TransactionSetControlNumber = transactionSetControlNumber - count += 1 - - message.BHT {|bht| - bht.HierarchicalStructureCode='0022' - bht.TransactionSetPurposeCode='13' - bht.ReferenceIdentification='LNKJNFGRWDLR' - bht.Date='20070724' - bht.Time='1726' - } - count += 1 - - message.L2000A {|l2000A| - l2000A.HL{|hl| - hl.HierarchicalIdNumber='1' - hl.HierarchicalParentIdNumber='' - hl.HierarchicalChildCode='1' - } - count += 1 - - l2000A.L2100A {|l2100A| - l2100A.NM1 {|nm1| - nm1.EntityIdentifierCode1='PR' - nm1.EntityTypeQualifier='2' - nm1.NameLastOrOrganizationName='RED CROSS' - nm1.IdentificationCodeQualifier='PI' - nm1.IdentificationCode='CHICAGO BLUES' - } - count += 1 - } - } - - message.L2000B {|l2000B| - l2000B.HL{|hl| - hl.HierarchicalIdNumber='2' - hl.HierarchicalParentIdNumber='1' - hl.HierarchicalChildCode='1' - } - count += 1 - - l2000B.L2100B {|l2100B| - l2100B.NM1 {|nm1| - nm1.EntityIdentifierCode1='1P' - nm1.EntityTypeQualifier='1' - nm1.NameLastOrOrganizationName='' - nm1.IdentificationCodeQualifier='SV' - nm1.IdentificationCode='daw' - } - count += 1 - } - } - - message.L2000C {|l2000C| - l2000C.HL{|hl| - hl.HierarchicalIdNumber='3' - hl.HierarchicalParentIdNumber='2' - hl.HierarchicalChildCode='0' - } - count += 1 - - l2000C.L2100C {|l2100C| - l2100C.NM1 {|nm1| - nm1.EntityIdentifierCode1='IL' - nm1.EntityTypeQualifier='1' - nm1.NameLastOrOrganizationName='LastName' - nm1.NameFirst='FirstName' - } - count += 1 - - l2100C.DMG {|dmg| - dmg.DateTimePeriodFormatQualifier='D8' - dmg.DateTimePeriod='19700725' - } - count += 1 - - l2100C.DTP {|dtp| - dtp.DateTimeQualifier='307' - dtp.DateTimePeriodFormatQualifier='D8' - dtp.DateTimePeriod='20070724' - } - count += 1 - - l2100C.L2110C {|l2110C| - l2110C.EQ {|eq| - eq.ServiceTypeCode='60' - } - count += 1 - } - } - } - - count += 1 - message.SE {|se| - se.NumberOfIncludedSegments = count - se.TransactionSetControlNumber = transactionSetControlNumber - } - - end # create_270 - - def create_fg(message, fg_num, num_of_270) - groupControlNumber = "00#{fg_num}" - - message.GS {|gs| - gs.FunctionalIdentifierCode='HS' - gs.ApplicationSendersCode='0000000Eliginet' - gs.ApplicationReceiversCode='CHICAGO BLUES' - gs.Date='20070724' - gs.Time='1726' - gs.GroupControlNumber=groupControlNumber - gs.ResponsibleAgencyCode='X' - gs.VersionReleaseIndustryIdentifierCode='004010X092A1' - } - - (1..num_of_270).each{|count| - create_270(message._270.repeat, fg_num, count-1) - } - - message.GE {|ge| - ge.NumberOfTransactionSetsIncluded=num_of_270 - ge.GroupControlNumber=groupControlNumber - } - end # create_fg - - def test_all - @r = @@p.factory('270interchange') - @r.ISA {|isa| - isa.AuthorizationInformationQualifier = '03' - isa.AuthorizationInformation = 'user ' - isa.SecurityInformationQualifier = '01' - isa.SecurityInformation = 'password ' - isa.InterchangeIdQualifier1 = 'ZZ' - isa.InterchangeSenderId = '0000000Eliginet' - isa.InterchangeIdQualifier2 = 'ZZ' - isa.InterchangeReceiverId = 'CHICAGO BLUES' - isa.InterchangeDate = '070724' - isa.InterchangeTime = '1726' - isa.InterchangeControlStandardsIdentifier = 'U' - isa.InterchangeControlVersionNumber = '00401' - isa.InterchangeControlNumber = '230623206' - isa.AcknowledgmentRuested = '0' - isa.UsageIndicator = 'T' - isa.ComponentElementSeparator = ':' - } - - fg_counter = 0 - @r.FG.repeat {|fg| - create_fg(fg, fg_counter, 3) - fg_counter += 1 - } - - @r.FG.repeat {|fg| - create_fg(fg, fg_counter, 2) - fg_counter += 1 - } - - @r.FG.repeat {|fg| - create_fg(fg, fg_counter, 1) - fg_counter += 1 - } - - @r.IEA {|iea| - iea.NumberOfIncludedFunctionalGroups=fg_counter - iea.InterchangeControlNumber = '230623206' - } - - assert_equal(@@result, @r.render) - end # test_all - - def test_timing - start = Time::now - X12::TEST_REPEAT.times do - test_all - end - finish = Time::now - puts sprintf("Factories per second, 270interchange: %.2f, elapsed: %.1f", X12::TEST_REPEAT.to_f/(finish-start), finish-start) - end # test_timing - -end # TestList diff --git a/test/tc_factory_997.rb b/test/tc_factory_997.rb deleted file mode 100644 index e350609..0000000 --- a/test/tc_factory_997.rb +++ /dev/null @@ -1,134 +0,0 @@ -#-- -# This file is part of the X12Parser library that provides tools to -# manipulate X12 messages using Ruby native syntax. -# -# http://x12parser.rubyforge.org -# -# Copyright (C) 2008 APP Design, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -#++ -# -require 'x12' -require 'test/unit' - -class Test997Factory < Test::Unit::TestCase - - @@p = nil -tmp=<<-EOT -ST*997*2878~ -AK1*HS*293328532~ -AK2*270*~ -AK3*NM1**L1000D~ -AK4***55*Bad element~ -AK5*A~ -AK3*DMG*0*L1010*22~ -AK4*0**0~ -AK4*0**1~ -AK4*1**0~ -AK4*1**1~ -AK5*E****999~ -AK9****~ -SE**~ -EOT - - @@result = tmp.gsub!(/\n/,'') - - def setup - unless @@p - # @@p = X12::Parser.new('misc/997single.xml') - @@p = X12::Parser.new('misc/997.xml') - end - end # setup - - def teardown - # Nothing - end # teardown - - def test_all - @r = @@p.factory('997') - - @r.ST.TransactionSetIdentifierCode = 997 - @r.ST.TransactionSetControlNumber = '2878' - - @r.AK1 { |ak1| - ak1.FunctionalIdentifierCode = 'HS' - ak1.GroupControlNumber = 293328532 - } - - @r.L1000.L1010.AK4.DataElementSyntaxErrorCode=55 - @r.L1000.AK2.TransactionSetIdentifierCode = 270 - @r.L1000.L1010 {|l| - l.AK3 {|s| - s.SegmentIdCode = 'NM1' - #SegmentPositionInTransactionSet - s.LoopIdentifierCode = 'L1000D' - #SegmentSyntaxErrorCode - } - - l.AK4 {|s| - #s.PositionInSegment = - #s.DataElementReferenceNumber = - #s.DataElementSyntaxErrorCode = - s.CopyOfBadDataElement = 'Bad element' - } - } - - @r.L1000.AK5{|a| - a.TransactionSetAcknowledgmentCode = 'A' - } # a - - # Should be two repeats in total - @r.L1000.repeat {|l1000| - (0..1).each {|loop_repeat| # Two repeats of the loop L1010 - l1000.L1010.repeat {|l1010| - - l1010.AK3 {|s| - s.SegmentIdCode = 'DMG' - s.SegmentPositionInTransactionSet = 0 - s.LoopIdentifierCode = 'L1010' - s.SegmentSyntaxErrorCode = 22 - } if loop_repeat == 0 # AK3 only in the first repeat of L1010 - - (0..1).each {|ak4_repeat| # Two repeats of the segment AK4 - l1010.AK4.repeat {|s| - s.PositionInSegment = loop_repeat - #s.DataElementReferenceNumber = - s.DataElementSyntaxErrorCode = ak4_repeat - #s.CopyOfBadDataElement = - } # s - } # ak4_repeat - } # l1010 - } # loop_repeat - - l1000.AK5{|a| - a.TransactionSetAcknowledgmentCode = 'E' - a.TransactionSetSyntaxErrorCode4 = 999 - } # a - } # l1000 - - assert_equal(@@result, @r.render) - end # test_all - - def test_timing - start = Time::now - X12::TEST_REPEAT.times do - test_all - end - finish = Time::now - puts sprintf("Factories per second, 997: %.2f, elapsed: %.1f", X12::TEST_REPEAT.to_f/(finish-start), finish-start) - end # test_timing - -end # TestList diff --git a/test/tc_parse_270.rb b/test/tc_parse_270.rb deleted file mode 100644 index 2574787..0000000 --- a/test/tc_parse_270.rb +++ /dev/null @@ -1,98 +0,0 @@ -#-- -# This file is part of the X12Parser library that provides tools to -# manipulate X12 messages using Ruby native syntax. -# -# http://x12parser.rubyforge.org -# -# Copyright (C) 2008 APP Design, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -#++ -# -require 'x12' -require 'test/unit' - -class Test270Parse < Test::Unit::TestCase - - @@p = nil - @@parser = X12::Parser.new('misc/270.xml') - - def setup - unless @@p - @@m=<<-EOT -ST*270*1001~ -BHT*0022*13*LNKJNFGRWDLR*20070724*1726~ -HL*1**20*1~ -NM1*PR*2*BIG PAYOR*****PI*CHICAGO BLUES~ -HL*2*1*21*1~ -NM1*1P*1******SV*daw~ -HL*3*2*22*0~ -NM1*IL*1*Doe*Joe~ -DMG*D8*19700725~ -DTP*307*D8*20070724~ -EQ*60~ -SE*12*1001~ -EOT - @@m.gsub!(/\n/,'') - - @@p = @@parser.parse('270', @@m) - # @@p.show - end - @r = @@p - - end # setup - - def teardown - # Nothing - end # teardown - - def test_ST - assert_equal('ST*270*1001~', @r.ST.to_s) - assert_equal('270', @r.ST.TransactionSetIdentifierCode) - end # test_ST - - def test_L2000A_NM1 - assert_equal('BIG PAYOR', @r.L2000A.L2100A.NM1.NameLastOrOrganizationName) - end - - def test_L2000C_NM1 - assert_equal('Joe', @r.L2000C.L2100C.NM1.NameFirst) - end - - def test_L2000A_HL - assert_equal('', @r.L2000A.HL.HierarchicalParentIdNumber) - end - - def test_absent - assert_equal(X12::EMPTY, @r.L2000D.HHH) - assert_equal(X12::EMPTY, @r.L2000B.L2111) - assert_equal('', @r.L2000C.L2100C.N3.AddressInformation1) - end # test_absent - - def test_timing - start = Time::now - X12::TEST_REPEAT.times do - @r = @@parser.parse('270', @@m) - test_ST - test_L2000A_NM1 - test_L2000C_NM1 - test_L2000A_HL - test_absent - end - finish = Time::now - puts sprintf("Parses per second, 270: %.2f, elapsed: %.1f", X12::TEST_REPEAT.to_f/(finish-start), finish-start) - end # test_timing - -end # TestParse diff --git a/test/tc_parse_270interchange.rb b/test/tc_parse_270interchange.rb deleted file mode 100644 index 983d9a9..0000000 --- a/test/tc_parse_270interchange.rb +++ /dev/null @@ -1,184 +0,0 @@ -#-- -# This file is part of the X12Parser library that provides tools to -# manipulate X12 messages using Ruby native syntax. -# -# http://x12parser.rubyforge.org -# -# Copyright (C) 2008 APP Design, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -#++ -# -require 'x12' -require 'test/unit' - -class Test270ParseInterchange < Test::Unit::TestCase - - @@p = nil - @@parser = X12::Parser.new('misc/270interchange.xml') - - def setup - unless @@p - @@m=<<-EOT -ISA*03*user *01*password *ZZ*0000000Eliginet*ZZ*CHICAGO BLUES*070724*1726*U*00401*230623206*0*T*:~ -GS*HS*0000000Eliginet*CHICAGO BLUES*20070724*1726*000*X*004010X092A1~ -ST*270*0000~ -BHT*0022*13*LNKJNFGRWDLR*20070724*1726~ -HL*1**20*1~ -NM1*PR*2*RED CROSS*****PI*CHICAGO BLUES~ -HL*2*1*21*1~ -NM1*1P*1******SV*daw~ -HL*3*2*22*0~ -NM1*IL*1*LastName*FirstName~ -DMG*D8*19700725~ -DTP*307*D8*20070724~ -EQ*60~ -SE*12*0000~ -ST*270*0001~ -BHT*0022*13*LNKJNFGRWDLR*20070724*1726~ -HL*1**20*1~ -NM1*PR*2*RED CROSS*****PI*CHICAGO BLUES~ -HL*2*1*21*1~ -NM1*1P*1******SV*daw~ -HL*3*2*22*0~ -NM1*IL*1*LastName*FirstName~ -DMG*D8*19700725~ -DTP*307*D8*20070724~ -EQ*60~ -SE*12*0001~ -ST*270*0002~ -BHT*0022*13*LNKJNFGRWDLR*20070724*1726~ -HL*1**20*1~ -NM1*PR*2*RED CROSS*****PI*CHICAGO BLUES~ -HL*2*1*21*1~ -NM1*1P*1******SV*daw~ -HL*3*2*22*0~ -NM1*IL*1*LastName*FirstName~ -DMG*D8*19700725~ -DTP*307*D8*20070724~ -EQ*60~ -SE*12*0002~ -GE*3*000~ -GS*HS*0000000Eliginet*CHICAGO BLUES*20070724*1726*001*X*004010X092A1~ -ST*270*1000~ -BHT*0022*13*LNKJNFGRWDLR*20070724*1726~ -HL*1**20*1~ -NM1*PR*2*RED CROSS*****PI*CHICAGO BLUES~ -HL*2*1*21*1~ -NM1*1P*1******SV*daw~ -HL*3*2*22*0~ -NM1*IL*1*LastName*FirstName~ -DMG*D8*19700725~ -DTP*307*D8*20070724~ -EQ*60~ -SE*12*1000~ -ST*270*1001~ -BHT*0022*13*LNKJNFGRWDLR*20070724*1726~ -HL*1**20*1~ -NM1*PR*2*RED CROSS*****PI*CHICAGO BLUES~ -HL*2*1*21*1~ -NM1*1P*1******SV*daw~ -HL*3*2*22*0~ -NM1*IL*1*LastName*FirstName~ -DMG*D8*19700725~ -DTP*307*D8*20070724~ -EQ*60~ -SE*12*1001~ -GE*2*001~ -GS*HS*0000000Eliginet*CHICAGO BLUES*20070724*1726*002*X*004010X092A1~ -ST*270*2000~ -BHT*0022*13*LNKJNFGRWDLR*20070724*1726~ -HL*1**20*1~ -NM1*PR*2*RED CROSS*****PI*CHICAGO BLUES~ -HL*2*1*21*1~ -NM1*1P*1******SV*daw~ -HL*3*2*22*0~ -NM1*IL*1*LastName*FirstName~ -DMG*D8*19700725~ -DTP*307*D8*20070724~ -EQ*60~ -SE*12*2000~ -GE*1*002~ -IEA*3*230623206~ -EOT - @@m.gsub!(/\n/,'') - - @@p = @@parser.parse('270interchange', @@m) - end - @r = @@p -# @@p.show - - end # setup - - def teardown - # Nothing - end # teardown - - def test_ISA_IEA - assert_equal('ISA*03*user *01*password *ZZ*0000000Eliginet*ZZ*CHICAGO BLUES*070724*1726*U*00401*230623206*0*T*:~', @r.ISA.to_s) - assert_equal('0000000Eliginet', @r.ISA.InterchangeSenderId) - assert_equal('3', @r.IEA.NumberOfIncludedFunctionalGroups) - - end # test_ST - - def test_FG - fg = @r.FG - assert_equal(3, fg.to_a.size) - assert_equal(3, fg.size) - assert_equal(3, fg[0].find('270').to_a.size) - assert_equal(2, fg[1].find('270').size) - assert_equal(1, fg[2]._270.size) - assert_equal('3', fg[0].GE.NumberOfTransactionSetsIncluded) - assert_equal('001', fg[1].GE.GroupControlNumber) - assert_equal('002', fg[2].GS.GroupControlNumber) - end - - def test_ST - assert_equal('ST*270*1001~', @r.FG[1]._270[1].ST.to_s) - assert_equal('270', @r.FG[1]._270[1].ST.TransactionSetIdentifierCode) - end # test_ST - - def test_L2000A_NM1 - assert_equal('RED CROSS', @r.FG[1]._270[1].L2000A.L2100A.NM1.NameLastOrOrganizationName) - end - - def test_L2000C_NM1 - @r.FG[1].with { |fg| - fg._270[1].with {|_270| - _270.L2000C {|l2000C| - l2000C.L2100C {|l2100C| - l2100C.NM1 {|nm1| - assert_equal('FirstName', nm1.NameFirst) - } - } - } - } - } - end - - def test_L2000A_HL - assert_equal('', @r.FG[1]._270[1].L2000A.HL.HierarchicalParentIdNumber) - end - - def test_timing - start = Time::now - X12::TEST_REPEAT.times do - @r = @@parser.parse('270interchange', @@m) - end - finish = Time::now - puts sprintf("Parses per second, 270interchange: %.2f, elapsed: %.1f", X12::TEST_REPEAT.to_f/(finish-start), finish-start) - end # test_timing - -end # TestParse diff --git a/test/tc_parse_997.rb b/test/tc_parse_997.rb deleted file mode 100644 index cad3f73..0000000 --- a/test/tc_parse_997.rb +++ /dev/null @@ -1,146 +0,0 @@ -#-- -# This file is part of the X12Parser library that provides tools to -# manipulate X12 messages using Ruby native syntax. -# -# http://x12parser.rubyforge.org -# -# Copyright (C) 2008 APP Design, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -#++ -# -require 'x12' -require 'test/unit' - -class Test997Parse < Test::Unit::TestCase - - @@p = nil -# @@parser = X12::Parser.new('misc/997single.xml') - @@parser = X12::Parser.new('misc/997.xml') - - def setup - unless @@p - @@m997=<<-EOT -ST*997*2878~ -AK1*HS*293328532~ -AK2*270*307272179~ -AK3*NM1*8*L1010_0*8~ -AK4*0:0*66*1~ -AK4*0:1*66*1~ -AK4*0:2*66*1~ -AK3*NM1*8*L1010_1*8~ -AK4*1:0*66*1~ -AK4*1:1*66*1~ -AK3*NM1*8*L1010_2*8~ -AK4*2:0*66*1~ -AK5*R*5~ -AK9*R*1*1*0~ -SE*8*2878~ -EOT - -# This should parse into -# 997 [0]: ST*997*2878~AK1*HS*293328532~A...AK5*R*5~AK9*R*1*1*0~SE*8*2878~ -# ST [0]: ST*997*2878~ -# AK1 [0]: AK1*HS*293328532~ -# L1000 [0]: AK2*270*307272179~AK3*NM1*8*L1...1010_2*8~AK4*2:0*66*1~AK5*R*5~ -# AK2 [0]: AK2*270*307272179~ -# L1010 [0]: AK3*NM1*8*L1010_0*8~AK4*0:0*66*1~AK4*0:1*66*1~AK4*0:2*66*1~ -# AK3 [0]: AK3*NM1*8*L1010_0*8~ -# AK4 [0]: AK4*0:0*66*1~ -# AK4 [1]: AK4*0:1*66*1~ -# AK4 [2]: AK4*0:2*66*1~ -# L1010 [1]: AK3*NM1*8*L1010_1*8~AK4*1:0*66*1~AK4*1:1*66*1~ -# AK3 [0]: AK3*NM1*8*L1010_1*8~ -# AK4 [0]: AK4*1:0*66*1~ -# AK4 [1]: AK4*1:1*66*1~ -# L1010 [2]: AK3*NM1*8*L1010_2*8~AK4*2:0*66*1~ -# AK3 [0]: AK3*NM1*8*L1010_2*8~ -# AK4 [0]: AK4*2:0*66*1~ -# AK5 [0]: AK5*R*5~ -# AK9 [0]: AK9*R*1*1*0~ -# SE [0]: SE*8*2878~ - - @@m997.gsub!(/\n/,'') - - @@p = @@parser.parse('997', @@m997) - end - @r = @@p - end # setup - - def teardown - # Nothing - end # teardown - - def test_ST - assert_equal('ST*997*2878~', @r.ST.to_s) - assert_equal('997', @r.ST.TransactionSetIdentifierCode) - end # test_ST - - def test_AK1 - assert_equal('293328532', @r.AK1.GroupControlNumber) - end # test_AK1 - - def test_AK2 - assert_equal('270', @r.L1000.AK2.TransactionSetIdentifierCode) - end # test_AK2 - - def test_L1010 - assert_match(/L1010_0/, @r.L1000.L1010.to_s) - assert_equal(3, @r.L1000.L1010.to_a.size) - assert_equal(3, @r.L1000.L1010.size) - assert_match(/L1010_2/, @r.L1000.L1010.to_a[2].to_s) - assert_match(/L1010_2/, @r.L1000.L1010[2].to_s) - end # test_L1010 - - def test_AK4 - assert_equal('AK4*1:0*66*1~', @r.L1000.L1010.to_a[1].AK4.to_s) - assert_equal('AK4*1:0*66*1~', @r.L1000.L1010[1].AK4.to_s) - assert_equal(3, @r.L1000.L1010.AK4.to_a.size) - assert_equal(3, @r.L1000.L1010.AK4.size) - assert_equal(2, @r.L1000.L1010.to_a[1].AK4.to_a.size) - assert_equal(2, @r.L1000.L1010[1].AK4.size) - assert_equal('AK4*1:1*66*1~', @r.L1000.L1010.to_a[1].AK4.to_a[1].to_s) - assert_equal('AK4*1:1*66*1~', @r.L1000.L1010[1].AK4[1].to_s) - assert_equal('66', @r.L1000.L1010.AK4.DataElementReferenceNumber) - end # test_AK4 - - def test_absent - assert_equal(X12::EMPTY, @r.L1000.AK8.TransactionSetIdentifierCode) - assert_equal(X12::EMPTY, @r.L1000.L1111) - assert_equal(X12::EMPTY, @r.L1000.L1111.L2222) - assert_equal(X12::EMPTY, @r.L1000.L1111.L2222.AFAFA) - assert_equal(X12::EMPTY, @r.L1000.L1010[-99]) - assert_equal(X12::EMPTY, @r.L1000.L1010[99]) - assert_equal(X12::EMPTY, @r.L1000.L1010[99].AK4) - - assert_equal('', @r.L1000.AK8.TransactionSetIdentifierCode.to_s) - end # test_absent - - def test_timing - start = Time::now - X12::TEST_REPEAT.times do - @r = @@parser.parse('997', @@m997) - test_ST - test_AK1 - test_AK2 - test_AK4 - test_L1010 - test_absent - end - finish = Time::now - puts sprintf("Parses per second, 997: %.2f, elapsed: %.1f", X12::TEST_REPEAT.to_f/(finish-start), finish-start) - end # test_timing - -end # TestList