Skip to content

Commit bdc3944

Browse files
laxmi-lal-menariamilkshakeuk
authored andcommitted
Added Testcase
Added Testcase for IncludeLongNameInEncodedXML. Test Method for Encode Test Method for Parser
1 parent 5426819 commit bdc3944

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/NHapi.NUnit/Parser/XMLParserTests.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,37 @@ public void Encode_AdtA01_CanBeParsedAgain()
374374
Console.WriteLine(decodedMessage.ToString());
375375
}
376376

377+
[Test]
378+
public void IncludeLongNameInEncodedXML_EncodingOptions()
379+
{
380+
var message = @"MSH|^~\&|KISsystem|ZTM|NIDAklinikserver|HL7Proxy|201902271130||ADT^A01|68371142|P|2.3
381+
EVN|A01|201902271130|201902271130";
382+
383+
var expectedEncodedMessage = @"<ADT_A01 xmlns=""urn:hl7-org:v2xml""><MSH><MSH.1 LongName=""Field Separator"">|</MSH.1><MSH.2 LongName=""Encoding Characters"">^~\&amp;</MSH.2><MSH.3 LongName=""Sending Application""><HD.1 LongName=""Namespace ID"">KISsystem</HD.1></MSH.3><MSH.4 LongName=""Sending Facility""><HD.1 LongName=""Namespace ID"">ZTM</HD.1></MSH.4><MSH.5 LongName=""Receiving Application""><HD.1 LongName=""Namespace ID"">NIDAklinikserver</HD.1></MSH.5><MSH.6 LongName=""Receiving Facility""><HD.1 LongName=""Namespace ID"">HL7Proxy</HD.1></MSH.6><MSH.7 LongName=""Date / Time of Message""><TS.1 LongName=""Time of an event"">201902271130</TS.1></MSH.7><MSH.9 LongName=""Message Type""><CM_MSG.1 LongName=""Message type"">ADT</CM_MSG.1><CM_MSG.2 LongName=""Trigger event"">A01</CM_MSG.2></MSH.9><MSH.10 LongName=""Message Control ID"">68371142</MSH.10><MSH.11 LongName=""Processing ID""><PT.1 LongName=""Processing ID"">P</PT.1></MSH.11><MSH.12 LongName=""Version ID"">2.3</MSH.12></MSH><EVN><EVN.1 LongName=""Event Type Code"">A01</EVN.1><EVN.2 LongName=""Recorded Date/Time""><TS.1 LongName=""Time of an event"">201902271130</TS.1></EVN.2><EVN.3 LongName=""Date/Time Planned Event""><TS.1 LongName=""Time of an event"">201902271130</TS.1></EVN.3></EVN></ADT_A01>";
384+
385+
var parser = new PipeParser();
386+
var options = new ParserOptions { IncludeLongNameInEncodedXml = true };
387+
388+
var parsed = parser.Parse(message, options);
389+
var encodedMessage = parser.Encode(parsed, options);
390+
391+
Assert.AreEqual(expectedEncodedMessage, encodedMessage);
392+
}
393+
394+
[Test]
395+
public void IncludeLongNameInEncodedXML_ParserOptions()
396+
{
397+
var message = @"MSH|^~\&|KISsystem|ZTM|NIDAklinikserver|HL7Proxy|201902271130||ADT^A01|68371142|P|2.3
398+
EVN|A01|201902271130|201902271130";
399+
400+
var parser = new PipeParser();
401+
var options = new ParserOptions { IncludeLongNameInEncodedXml = true };
402+
403+
var parsed = parser.Parse(message, options);
404+
405+
Assert.AreEqual("201902271130", ((NHapi.Model.V23.Message.ADT_A01)parsed).EVN.DateTimePlannedEvent.TimeOfAnEvent.Value);
406+
}
407+
377408
private static void SetMessageHeader(IMessage msg, string messageCode, string messageTriggerEvent, string processingId)
378409
{
379410
var msh = (ISegment)msg.GetStructure("MSH");

0 commit comments

Comments
 (0)