diff --git a/src/ClearHl7/ClearHl7.csproj b/src/ClearHl7/ClearHl7.csproj
index 75b69ab96..04d7c842a 100644
--- a/src/ClearHl7/ClearHl7.csproj
+++ b/src/ClearHl7/ClearHl7.csproj
@@ -24,11 +24,4 @@
latest
bin\Release\netstandard2.0\ClearHl7.xml
-
-
-
-
-
-
-
diff --git a/src/ClearHl7/Consts.cs b/src/ClearHl7/Consts.cs
index 23d31409d..627411d38 100644
--- a/src/ClearHl7/Consts.cs
+++ b/src/ClearHl7/Consts.cs
@@ -5,6 +5,11 @@
///
public static class Consts
{
+ ///
+ /// Standard Message line terminator.
+ ///
+ public const char LineTerminator = (char)13;
+
///
/// Default field separator.
///
diff --git a/src/ClearHl7/Helpers/MessageHelper.cs b/src/ClearHl7/Helpers/MessageHelper.cs
index 8c68b0375..8b285f6ca 100644
--- a/src/ClearHl7/Helpers/MessageHelper.cs
+++ b/src/ClearHl7/Helpers/MessageHelper.cs
@@ -47,7 +47,7 @@ public static Hl7Version DetectVersion(string delimitedString)
startPosition++;
// Find the ending position of the version identifier
- int endPosition = delimitedString.IndexOfAny(new[] { fieldSeparator, delimitedString[4], (char)13 }, startPosition);
+ int endPosition = delimitedString.IndexOfAny(new[] { fieldSeparator, delimitedString[4], Consts.LineTerminator }, startPosition);
if (endPosition == -1)
{
diff --git a/src/ClearHl7/Serialization/MessageSerializer.cs b/src/ClearHl7/Serialization/MessageSerializer.cs
index 94ed7b297..46d716659 100644
--- a/src/ClearHl7/Serialization/MessageSerializer.cs
+++ b/src/ClearHl7/Serialization/MessageSerializer.cs
@@ -73,7 +73,7 @@ public static T Deserialize(string delimitedString) where T : class, IMessage
CultureInfo culture = CultureInfo.CurrentCulture;
string[] segments = delimitedString == null
? Array.Empty()
- : delimitedString.Split(new char[] { (char)13 }, StringSplitOptions.RemoveEmptyEntries);
+ : delimitedString.Split(new char[] { Consts.LineTerminator }, StringSplitOptions.RemoveEmptyEntries);
List list = new();
Type messageClass = item.GetType();
diff --git a/src/ClearHl7/V230/Message.cs b/src/ClearHl7/V230/Message.cs
index c8a89ce0a..24341039d 100644
--- a/src/ClearHl7/V230/Message.cs
+++ b/src/ClearHl7/V230/Message.cs
@@ -44,7 +44,7 @@ public string ToDelimitedString()
}
output.Append(item.ToDelimitedString());
- output.Append((char)13);
+ output.Append(Consts.LineTerminator);
}
}
diff --git a/src/ClearHl7/V231/Message.cs b/src/ClearHl7/V231/Message.cs
index ca9775b05..13cbee23a 100644
--- a/src/ClearHl7/V231/Message.cs
+++ b/src/ClearHl7/V231/Message.cs
@@ -44,7 +44,7 @@ public string ToDelimitedString()
}
output.Append(item.ToDelimitedString());
- output.Append((char)13);
+ output.Append(Consts.LineTerminator);
}
}
diff --git a/src/ClearHl7/V240/Message.cs b/src/ClearHl7/V240/Message.cs
index 6906753c9..19c198185 100644
--- a/src/ClearHl7/V240/Message.cs
+++ b/src/ClearHl7/V240/Message.cs
@@ -44,7 +44,7 @@ public string ToDelimitedString()
}
output.Append(item.ToDelimitedString());
- output.Append((char)13);
+ output.Append(Consts.LineTerminator);
}
}
diff --git a/src/ClearHl7/V250/Message.cs b/src/ClearHl7/V250/Message.cs
index f2fac2a99..8f7c927da 100644
--- a/src/ClearHl7/V250/Message.cs
+++ b/src/ClearHl7/V250/Message.cs
@@ -44,7 +44,7 @@ public string ToDelimitedString()
}
output.Append(item.ToDelimitedString());
- output.Append((char)13);
+ output.Append(Consts.LineTerminator);
}
}
diff --git a/src/ClearHl7/V251/Message.cs b/src/ClearHl7/V251/Message.cs
index d229f6fec..552d5254d 100644
--- a/src/ClearHl7/V251/Message.cs
+++ b/src/ClearHl7/V251/Message.cs
@@ -44,7 +44,7 @@ public string ToDelimitedString()
}
output.Append(item.ToDelimitedString());
- output.Append((char)13);
+ output.Append(Consts.LineTerminator);
}
}
diff --git a/src/ClearHl7/V260/Message.cs b/src/ClearHl7/V260/Message.cs
index 0f702c30e..7b33ce25e 100644
--- a/src/ClearHl7/V260/Message.cs
+++ b/src/ClearHl7/V260/Message.cs
@@ -44,7 +44,7 @@ public string ToDelimitedString()
}
output.Append(item.ToDelimitedString());
- output.Append((char)13);
+ output.Append(Consts.LineTerminator);
}
}
diff --git a/src/ClearHl7/V270/Message.cs b/src/ClearHl7/V270/Message.cs
index 3072556b4..4d1d0046c 100644
--- a/src/ClearHl7/V270/Message.cs
+++ b/src/ClearHl7/V270/Message.cs
@@ -44,7 +44,7 @@ public string ToDelimitedString()
}
output.Append(item.ToDelimitedString());
- output.Append((char)13);
+ output.Append(Consts.LineTerminator);
}
}
diff --git a/src/ClearHl7/V271/Message.cs b/src/ClearHl7/V271/Message.cs
index 0892c6912..8398a2287 100644
--- a/src/ClearHl7/V271/Message.cs
+++ b/src/ClearHl7/V271/Message.cs
@@ -44,7 +44,7 @@ public string ToDelimitedString()
}
output.Append(item.ToDelimitedString());
- output.Append((char)13);
+ output.Append(Consts.LineTerminator);
}
}
diff --git a/src/ClearHl7/V280/Message.cs b/src/ClearHl7/V280/Message.cs
index 9f5063a80..4c19b4ac1 100644
--- a/src/ClearHl7/V280/Message.cs
+++ b/src/ClearHl7/V280/Message.cs
@@ -44,7 +44,7 @@ public string ToDelimitedString()
}
output.Append(item.ToDelimitedString());
- output.Append((char)13);
+ output.Append(Consts.LineTerminator);
}
}
diff --git a/src/ClearHl7/V281/Message.cs b/src/ClearHl7/V281/Message.cs
index 84e9ecee9..6b849471e 100644
--- a/src/ClearHl7/V281/Message.cs
+++ b/src/ClearHl7/V281/Message.cs
@@ -44,7 +44,7 @@ public string ToDelimitedString()
}
output.Append(item.ToDelimitedString());
- output.Append((char)13);
+ output.Append(Consts.LineTerminator);
}
}
diff --git a/src/ClearHl7/V282/Message.cs b/src/ClearHl7/V282/Message.cs
index 71d0e1e4a..e1ea31584 100644
--- a/src/ClearHl7/V282/Message.cs
+++ b/src/ClearHl7/V282/Message.cs
@@ -44,7 +44,7 @@ public string ToDelimitedString()
}
output.Append(item.ToDelimitedString());
- output.Append((char)13);
+ output.Append(Consts.LineTerminator);
}
}
diff --git a/src/ClearHl7/V290/Message.cs b/src/ClearHl7/V290/Message.cs
index bd6c3898d..a2aadaf4b 100644
--- a/src/ClearHl7/V290/Message.cs
+++ b/src/ClearHl7/V290/Message.cs
@@ -44,7 +44,7 @@ public string ToDelimitedString()
}
output.Append(item.ToDelimitedString());
- output.Append((char)13);
+ output.Append(Consts.LineTerminator);
}
}
diff --git a/test/ClearHl7.Tests/HelpersTests/MessageHelperTests.cs b/test/ClearHl7.Tests/HelpersTests/MessageHelperTests.cs
index 1dd302d70..c5a6b6e72 100644
--- a/test/ClearHl7.Tests/HelpersTests/MessageHelperTests.cs
+++ b/test/ClearHl7.Tests/HelpersTests/MessageHelperTests.cs
@@ -12,7 +12,7 @@ public class MessageHelperTests
[Fact]
public void DetectVersion_With23Specified_ReturnsCorrectHl7Version()
{
- Assert.True(MessageHelper.DetectVersion(@"MSH|^~\&||||||||||2.3||") == Hl7Version.V230);
+ Assert.True(MessageHelper.DetectVersion($"{ @"MSH|^~\&||||||||||2.3||" }{ Consts.LineTerminator }") == Hl7Version.V230);
}
///
@@ -21,7 +21,7 @@ public void DetectVersion_With23Specified_ReturnsCorrectHl7Version()
[Fact]
public void DetectVersion_With230Specified_ReturnsCorrectHl7Version()
{
- Assert.True(MessageHelper.DetectVersion(@"MSH|^~\&||||||||||2.3.0||") == Hl7Version.V230);
+ Assert.True(MessageHelper.DetectVersion($"{ @"MSH|^~\&||||||||||2.3.0||" }{ Consts.LineTerminator }") == Hl7Version.V230);
}
///
@@ -30,7 +30,7 @@ public void DetectVersion_With230Specified_ReturnsCorrectHl7Version()
[Fact]
public void DetectVersion_With231Specified_ReturnsCorrectHl7Version()
{
- Assert.True(MessageHelper.DetectVersion(@"MSH|^~\&||||||||||2.3.1||") == Hl7Version.V231);
+ Assert.True(MessageHelper.DetectVersion($"{ @"MSH|^~\&||||||||||2.3.1||" }{ Consts.LineTerminator }") == Hl7Version.V231);
}
///
@@ -39,7 +39,7 @@ public void DetectVersion_With231Specified_ReturnsCorrectHl7Version()
[Fact]
public void DetectVersion_With24Specified_ReturnsCorrectHl7Version()
{
- Assert.True(MessageHelper.DetectVersion(@"MSH|^~\&||||||||||2.4||") == Hl7Version.V240);
+ Assert.True(MessageHelper.DetectVersion($"{ @"MSH|^~\&||||||||||2.4||" }{ Consts.LineTerminator }") == Hl7Version.V240);
}
///
@@ -48,7 +48,7 @@ public void DetectVersion_With24Specified_ReturnsCorrectHl7Version()
[Fact]
public void DetectVersion_With240Specified_ReturnsCorrectHl7Version()
{
- Assert.True(MessageHelper.DetectVersion(@"MSH|^~\&||||||||||2.4.0||") == Hl7Version.V240);
+ Assert.True(MessageHelper.DetectVersion($"{ @"MSH|^~\&||||||||||2.4.0||" }{ Consts.LineTerminator }") == Hl7Version.V240);
}
///
@@ -57,7 +57,7 @@ public void DetectVersion_With240Specified_ReturnsCorrectHl7Version()
[Fact]
public void DetectVersion_With25Specified_ReturnsCorrectHl7Version()
{
- Assert.True(MessageHelper.DetectVersion(@"MSH|^~\&||||||||||2.5||") == Hl7Version.V250);
+ Assert.True(MessageHelper.DetectVersion($"{ @"MSH|^~\&||||||||||2.5||" }{ Consts.LineTerminator }") == Hl7Version.V250);
}
///
@@ -66,7 +66,7 @@ public void DetectVersion_With25Specified_ReturnsCorrectHl7Version()
[Fact]
public void DetectVersion_With250Specified_ReturnsCorrectHl7Version()
{
- Assert.True(MessageHelper.DetectVersion(@"MSH|^~\&||||||||||2.5.0||") == Hl7Version.V250);
+ Assert.True(MessageHelper.DetectVersion($"{ @"MSH|^~\&||||||||||2.5.0||" }{ Consts.LineTerminator }") == Hl7Version.V250);
}
///
@@ -75,7 +75,7 @@ public void DetectVersion_With250Specified_ReturnsCorrectHl7Version()
[Fact]
public void DetectVersion_With251Specified_ReturnsCorrectHl7Version()
{
- Assert.True(MessageHelper.DetectVersion(@"MSH|^~\&||||||||||2.5.1||") == Hl7Version.V251);
+ Assert.True(MessageHelper.DetectVersion($"{ @"MSH|^~\&||||||||||2.5.1||" }{ Consts.LineTerminator }") == Hl7Version.V251);
}
///
@@ -84,7 +84,7 @@ public void DetectVersion_With251Specified_ReturnsCorrectHl7Version()
[Fact]
public void DetectVersion_With26Specified_ReturnsCorrectHl7Version()
{
- Assert.True(MessageHelper.DetectVersion(@"MSH|^~\&||||||||||2.6||") == Hl7Version.V260);
+ Assert.True(MessageHelper.DetectVersion($"{ @"MSH|^~\&||||||||||2.6||" }{ Consts.LineTerminator }") == Hl7Version.V260);
}
///
@@ -93,7 +93,7 @@ public void DetectVersion_With26Specified_ReturnsCorrectHl7Version()
[Fact]
public void DetectVersion_With260Specified_ReturnsCorrectHl7Version()
{
- Assert.True(MessageHelper.DetectVersion(@"MSH|^~\&||||||||||2.6.0||") == Hl7Version.V260);
+ Assert.True(MessageHelper.DetectVersion($"{ @"MSH|^~\&||||||||||2.6.0||" }{ Consts.LineTerminator }") == Hl7Version.V260);
}
///
@@ -102,7 +102,7 @@ public void DetectVersion_With260Specified_ReturnsCorrectHl7Version()
[Fact]
public void DetectVersion_With27Specified_ReturnsCorrectHl7Version()
{
- Assert.True(MessageHelper.DetectVersion(@"MSH|^~\&||||||||||2.7||") == Hl7Version.V270);
+ Assert.True(MessageHelper.DetectVersion($"{ @"MSH|^~\&||||||||||2.7||" }{ Consts.LineTerminator }") == Hl7Version.V270);
}
///
@@ -111,7 +111,7 @@ public void DetectVersion_With27Specified_ReturnsCorrectHl7Version()
[Fact]
public void DetectVersion_With270Specified_ReturnsCorrectHl7Version()
{
- Assert.True(MessageHelper.DetectVersion(@"MSH|^~\&||||||||||2.7.0||") == Hl7Version.V270);
+ Assert.True(MessageHelper.DetectVersion($"{ @"MSH|^~\&||||||||||2.7.0||" }{ Consts.LineTerminator }") == Hl7Version.V270);
}
///
@@ -120,7 +120,7 @@ public void DetectVersion_With270Specified_ReturnsCorrectHl7Version()
[Fact]
public void DetectVersion_With271Specified_ReturnsCorrectHl7Version()
{
- Assert.True(MessageHelper.DetectVersion(@"MSH|^~\&||||||||||2.7.1||") == Hl7Version.V271);
+ Assert.True(MessageHelper.DetectVersion($"{ @"MSH|^~\&||||||||||2.7.1||" }{ Consts.LineTerminator }") == Hl7Version.V271);
}
///
@@ -129,7 +129,7 @@ public void DetectVersion_With271Specified_ReturnsCorrectHl7Version()
[Fact]
public void DetectVersion_With28Specified_ReturnsCorrectHl7Version()
{
- Assert.True(MessageHelper.DetectVersion(@"MSH|^~\&||||||||||2.8||") == Hl7Version.V280);
+ Assert.True(MessageHelper.DetectVersion($"{ @"MSH|^~\&||||||||||2.8||" }{ Consts.LineTerminator }") == Hl7Version.V280);
}
///
@@ -138,7 +138,7 @@ public void DetectVersion_With28Specified_ReturnsCorrectHl7Version()
[Fact]
public void DetectVersion_With280Specified_ReturnsCorrectHl7Version()
{
- Assert.True(MessageHelper.DetectVersion(@"MSH|^~\&||||||||||2.8.0||") == Hl7Version.V280);
+ Assert.True(MessageHelper.DetectVersion($"{ @"MSH|^~\&||||||||||2.8.0||" }{ Consts.LineTerminator }") == Hl7Version.V280);
}
///
@@ -147,7 +147,7 @@ public void DetectVersion_With280Specified_ReturnsCorrectHl7Version()
[Fact]
public void DetectVersion_With281Specified_ReturnsCorrectHl7Version()
{
- Assert.True(MessageHelper.DetectVersion(@"MSH|^~\&||||||||||2.8.1||") == Hl7Version.V281);
+ Assert.True(MessageHelper.DetectVersion($"{ @"MSH|^~\&||||||||||2.8.1||" }{ Consts.LineTerminator }") == Hl7Version.V281);
}
///
@@ -156,7 +156,7 @@ public void DetectVersion_With281Specified_ReturnsCorrectHl7Version()
[Fact]
public void DetectVersion_With282Specified_ReturnsCorrectHl7Version()
{
- Assert.True(MessageHelper.DetectVersion(@"MSH|^~\&||||||||||2.8.2||") == Hl7Version.V282);
+ Assert.True(MessageHelper.DetectVersion($"{ @"MSH|^~\&||||||||||2.8.2||" }{ Consts.LineTerminator }") == Hl7Version.V282);
}
///
@@ -165,7 +165,7 @@ public void DetectVersion_With282Specified_ReturnsCorrectHl7Version()
[Fact]
public void DetectVersion_With29Specified_ReturnsCorrectHl7Version()
{
- Assert.True(MessageHelper.DetectVersion(@"MSH|^~\&||||||||||2.9||") == Hl7Version.V290);
+ Assert.True(MessageHelper.DetectVersion($"{ @"MSH|^~\&||||||||||2.9||" }{ Consts.LineTerminator }") == Hl7Version.V290);
}
///
@@ -174,7 +174,7 @@ public void DetectVersion_With29Specified_ReturnsCorrectHl7Version()
[Fact]
public void DetectVersion_With290Specified_ReturnsCorrectHl7Version()
{
- Assert.True(MessageHelper.DetectVersion(@"MSH|^~\&||||||||||2.9.0||") == Hl7Version.V290);
+ Assert.True(MessageHelper.DetectVersion($"{ @"MSH|^~\&||||||||||2.9.0||" }{ Consts.LineTerminator }") == Hl7Version.V290);
}
///
@@ -183,7 +183,7 @@ public void DetectVersion_With290Specified_ReturnsCorrectHl7Version()
[Fact]
public void DetectVersion_WithMultipleComponentsInPositionTwelve_ReturnsCorrectHl7Version()
{
- Assert.True(MessageHelper.DetectVersion(@"MSH|^~\&||||||||||2.5.1^something else||") == Hl7Version.V251);
+ Assert.True(MessageHelper.DetectVersion($"{ @"MSH|^~\&||||||||||2.5.1^something else||" }{ Consts.LineTerminator }") == Hl7Version.V251);
}
///
@@ -192,7 +192,7 @@ public void DetectVersion_WithMultipleComponentsInPositionTwelve_ReturnsCorrectH
[Fact]
public void DetectVersion_WithCustomComponentSeparator_ReturnsCorrectHl7Version()
{
- Assert.True(MessageHelper.DetectVersion(@"MSH|$~\&||||||||||2.5.1$something else||") == Hl7Version.V251);
+ Assert.True(MessageHelper.DetectVersion($"{ @"MSH|$~\&||||||||||2.5.1$something else||" }{ Consts.LineTerminator }") == Hl7Version.V251);
}
///
@@ -201,7 +201,7 @@ public void DetectVersion_WithCustomComponentSeparator_ReturnsCorrectHl7Version(
[Fact]
public void DetectVersion_WithCustomFieldSeparator_ReturnsCorrectHl7Version()
{
- Assert.True(MessageHelper.DetectVersion(@"MSH$^~\&$$$$$$$$$$2.5.1$$") == Hl7Version.V251);
+ Assert.True(MessageHelper.DetectVersion($"{ @"MSH$^~\&$$$$$$$$$$2.5.1$$" }{ Consts.LineTerminator }") == Hl7Version.V251);
}
///
@@ -210,7 +210,7 @@ public void DetectVersion_WithCustomFieldSeparator_ReturnsCorrectHl7Version()
[Fact]
public void DetectVersion_WithExactly12Positions_ReturnsCorrectHl7Version()
{
- Assert.True(MessageHelper.DetectVersion($"{ @"MSH|^~\&||||||||||2.5.1" }{ (char)13 }") == Hl7Version.V251);
+ Assert.True(MessageHelper.DetectVersion($"{ @"MSH|^~\&||||||||||2.5.1" }{ Consts.LineTerminator }") == Hl7Version.V251);
}
///
@@ -219,7 +219,7 @@ public void DetectVersion_WithExactly12Positions_ReturnsCorrectHl7Version()
[Fact]
public void DetectVersion_WithLessThan12Positions_ReturnsCorrectHl7Version()
{
- Assert.True(MessageHelper.DetectVersion(@"MSH|^~\&||||||") == Hl7Version.None);
+ Assert.True(MessageHelper.DetectVersion($"{ @"MSH|^~\&||||||" }{ Consts.LineTerminator }") == Hl7Version.None);
}
///
@@ -254,7 +254,7 @@ public void DetectVersion_WithInvalidFirstSegment_ThrowsArgumentException()
{
Assert.Throws(() =>
{
- MessageHelper.DetectVersion(@"ABC|^~\&||||||||||2.8.0||");
+ MessageHelper.DetectVersion($"{ @"ABC|^~\&||||||||||2.8.0||" }{ Consts.LineTerminator }");
});
}
diff --git a/test/ClearHl7.Tests/MessagesTests/MessageTests.cs b/test/ClearHl7.Tests/MessagesTests/MessageTests.cs
index cc8a79d99..d4e2671c7 100644
--- a/test/ClearHl7.Tests/MessagesTests/MessageTests.cs
+++ b/test/ClearHl7.Tests/MessagesTests/MessageTests.cs
@@ -91,7 +91,7 @@ public void FromDelimitedString_WithAllProperties_ReturnsCorrectlyInitializedFie
};
IMessage actual = new Message();
- actual.FromDelimitedString("MSH|^~\\&|Sender 1||Receiver 1||20201202144539|||||2.9\rIN1|15|MNO Healthcare|736HB^^^DES1&UID654&Type 5~AA876^^^LLL098&UID123&Type 7\rCDM||Code 1^ABC~Code 2^ZYX\r");
+ actual.FromDelimitedString($"MSH|^~\\&|Sender 1||Receiver 1||20201202144539|||||2.9{ Consts.LineTerminator }IN1|15|MNO Healthcare|736HB^^^DES1&UID654&Type 5~AA876^^^LLL098&UID123&Type 7{ Consts.LineTerminator }CDM||Code 1^ABC~Code 2^ZYX{ Consts.LineTerminator }");
expected.Should().BeEquivalentTo(actual);
}
@@ -178,7 +178,7 @@ public void FromDelimitedString_WithCustomDelimiters_ReturnsCorrectlyInitialized
};
IMessage actual = new Message();
- actual.FromDelimitedString("MSH~$*\\-~Sender 1~~Receiver 1~~20201202144539~~~~~2.9\rIN1~15~MNO Healthcare~736HB$$$DES1-UID654-Type 5*AA876$$$LLL09--UID123-Type 7\rCDM~~Code 1$ABC*Code 2$ZYX\r");
+ actual.FromDelimitedString($"MSH~$*\\-~Sender 1~~Receiver 1~~20201202144539~~~~~2.9{ Consts.LineTerminator }IN1~15~MNO Healthcare~736HB$$$DES1-UID654-Type 5*AA876$$$LLL09--UID123-Type 7{ Consts.LineTerminator }CDM~~Code 1$ABC*Code 2$ZYX{ Consts.LineTerminator }");
expected.Should().BeEquivalentTo(actual);
}
@@ -264,7 +264,7 @@ public void ToDelimitedString_WithThreeSegments_ReturnsCorrectMessage()
}
};
- string expected = "MSH|^~\\&|Sender 1||Receiver 1||20201202144539|||||2.9\rIN1|15|MNO Healthcare|736HB^^^DES1&UID654&Type 5~AA876^^^LLL098&UID123&Type 7\rCDM||Code 1^ABC~Code 2^ZYX\r";
+ string expected = $"MSH|^~\\&|Sender 1||Receiver 1||20201202144539|||||2.9{ Consts.LineTerminator }IN1|15|MNO Healthcare|736HB^^^DES1&UID654&Type 5~AA876^^^LLL098&UID123&Type 7{ Consts.LineTerminator }CDM||Code 1^ABC~Code 2^ZYX{ Consts.LineTerminator }";
string actual = message.ToDelimitedString();
Assert.Equal(expected, actual);
diff --git a/test/ClearHl7.Tests/SerializationTests/MessageSerializerTests.cs b/test/ClearHl7.Tests/SerializationTests/MessageSerializerTests.cs
index cb80464f5..eafe61307 100644
--- a/test/ClearHl7.Tests/SerializationTests/MessageSerializerTests.cs
+++ b/test/ClearHl7.Tests/SerializationTests/MessageSerializerTests.cs
@@ -91,7 +91,7 @@ public void Deserialize_WithThreeSegments_ReturnsCorrectlyInitializedFields()
}
};
- string delimitedString = "MSH|^~\\&|Sender 1||Receiver 1||20201202144539|||||2.9\rIN1|15|MNO Healthcare|736HB^^^DES1&UID654&Type 5~AA876^^^LLL098&UID123&Type 7\rCDM||Code 1^ABC~Code 2^ZYX\r";
+ string delimitedString = $"MSH|^~\\&|Sender 1||Receiver 1||20201202144539|||||2.9{ Consts.LineTerminator }IN1|15|MNO Healthcare|736HB^^^DES1&UID654&Type 5~AA876^^^LLL098&UID123&Type 7{ Consts.LineTerminator }CDM||Code 1^ABC~Code 2^ZYX{ Consts.LineTerminator }";
Message actual = MessageSerializer.Deserialize(delimitedString);
expected.Should().BeEquivalentTo(actual);
@@ -178,7 +178,7 @@ public void Deserialize_WithCustomFieldSeparator_ReturnsCorrectlyInitializedFiel
}
};
- string delimitedString = "MSH$^~\\&$Sender 1$$Receiver 1$$20201202144539$$$$$2.9\rIN1$15$MNO Healthcare$736HB^^^DES1&UID654&Type 5~AA876^^^LLL098&UID123&Type 7\rCDM$$Code 1^ABC~Code 2^ZYX\r";
+ string delimitedString = $"MSH$^~\\&$Sender 1$$Receiver 1$$20201202144539$$$$$2.9{ Consts.LineTerminator }IN1$15$MNO Healthcare$736HB^^^DES1&UID654&Type 5~AA876^^^LLL098&UID123&Type 7{ Consts.LineTerminator }CDM$$Code 1^ABC~Code 2^ZYX{ Consts.LineTerminator }";
Message actual = MessageSerializer.Deserialize(delimitedString);
expected.Should().BeEquivalentTo(actual);
@@ -204,7 +204,7 @@ public void Deserialize_WithInvalidVersionSpecified_ThrowsArgumentException()
{
Assert.Throws(() =>
{
- MessageSerializer.Deserialize(@"MSH|^~\&||||||||||2.2.7||");
+ MessageSerializer.Deserialize($"{ @"MSH|^~\&||||||||||2.2.7||" }{ Consts.LineTerminator }");
});
}
@@ -214,7 +214,7 @@ public void Deserialize_WithInvalidVersionSpecified_ThrowsArgumentException()
[Fact]
public void Deserialize_With23Specified_ReturnsCorrectMesssageVersion()
{
- Assert.IsType(MessageSerializer.Deserialize(@"MSH|^~\&||||||||||2.3||"));
+ Assert.IsType(MessageSerializer.Deserialize($"{ @"MSH|^~\&||||||||||2.3||" }{ Consts.LineTerminator }"));
}
///
@@ -223,7 +223,7 @@ public void Deserialize_With23Specified_ReturnsCorrectMesssageVersion()
[Fact]
public void Deserialize_With231Specified_ReturnsCorrectMesssageVersion()
{
- Assert.IsType(MessageSerializer.Deserialize(@"MSH|^~\&||||||||||2.3.1||"));
+ Assert.IsType(MessageSerializer.Deserialize($"{ @"MSH|^~\&||||||||||2.3.1||" }{ Consts.LineTerminator }"));
}
///
@@ -232,7 +232,7 @@ public void Deserialize_With231Specified_ReturnsCorrectMesssageVersion()
[Fact]
public void Deserialize_With24Specified_ReturnsCorrectMesssageVersion()
{
- Assert.IsType(MessageSerializer.Deserialize(@"MSH|^~\&||||||||||2.4||"));
+ Assert.IsType(MessageSerializer.Deserialize($"{ @"MSH|^~\&||||||||||2.4||" }{ Consts.LineTerminator }"));
}
///
@@ -241,7 +241,7 @@ public void Deserialize_With24Specified_ReturnsCorrectMesssageVersion()
[Fact]
public void Deserialize_With25Specified_ReturnsCorrectMesssageVersion()
{
- Assert.IsType(MessageSerializer.Deserialize(@"MSH|^~\&||||||||||2.5||"));
+ Assert.IsType(MessageSerializer.Deserialize($"{ @"MSH|^~\&||||||||||2.5||" }{ Consts.LineTerminator }"));
}
///
@@ -250,7 +250,7 @@ public void Deserialize_With25Specified_ReturnsCorrectMesssageVersion()
[Fact]
public void Deserialize_With251Specified_ReturnsCorrectMesssageVersion()
{
- Assert.IsType(MessageSerializer.Deserialize(@"MSH|^~\&||||||||||2.5.1||"));
+ Assert.IsType(MessageSerializer.Deserialize($"{ @"MSH|^~\&||||||||||2.5.1||" }{ Consts.LineTerminator }"));
}
///
@@ -259,7 +259,7 @@ public void Deserialize_With251Specified_ReturnsCorrectMesssageVersion()
[Fact]
public void Deserialize_With26Specified_ReturnsCorrectMesssageVersion()
{
- Assert.IsType(MessageSerializer.Deserialize(@"MSH|^~\&||||||||||2.6||"));
+ Assert.IsType(MessageSerializer.Deserialize($"{ @"MSH|^~\&||||||||||2.6||" }{ Consts.LineTerminator }"));
}
///
@@ -268,7 +268,7 @@ public void Deserialize_With26Specified_ReturnsCorrectMesssageVersion()
[Fact]
public void Deserialize_With27Specified_ReturnsCorrectMesssageVersion()
{
- Assert.IsType(MessageSerializer.Deserialize(@"MSH|^~\&||||||||||2.7||"));
+ Assert.IsType(MessageSerializer.Deserialize($"{ @"MSH|^~\&||||||||||2.7||" }{ Consts.LineTerminator }"));
}
///
@@ -277,7 +277,7 @@ public void Deserialize_With27Specified_ReturnsCorrectMesssageVersion()
[Fact]
public void Deserialize_With271Specified_ReturnsCorrectMesssageVersion()
{
- Assert.IsType(MessageSerializer.Deserialize(@"MSH|^~\&||||||||||2.7.1||"));
+ Assert.IsType(MessageSerializer.Deserialize($"{ @"MSH|^~\&||||||||||2.7.1||" }{ Consts.LineTerminator }"));
}
///
@@ -286,7 +286,7 @@ public void Deserialize_With271Specified_ReturnsCorrectMesssageVersion()
[Fact]
public void Deserialize_With28Specified_ReturnsCorrectMesssageVersion()
{
- Assert.IsType(MessageSerializer.Deserialize(@"MSH|^~\&||||||||||2.8||"));
+ Assert.IsType(MessageSerializer.Deserialize($"{ @"MSH|^~\&||||||||||2.8||" }{ Consts.LineTerminator }"));
}
///
@@ -295,7 +295,7 @@ public void Deserialize_With28Specified_ReturnsCorrectMesssageVersion()
[Fact]
public void Deserialize_With281Specified_ReturnsCorrectMesssageVersion()
{
- Assert.IsType(MessageSerializer.Deserialize(@"MSH|^~\&||||||||||2.8.1||"));
+ Assert.IsType(MessageSerializer.Deserialize($"{ @"MSH|^~\&||||||||||2.8.1||" }{ Consts.LineTerminator }"));
}
///
@@ -304,7 +304,7 @@ public void Deserialize_With281Specified_ReturnsCorrectMesssageVersion()
[Fact]
public void Deserialize_With282Specified_ReturnsCorrectMesssageVersion()
{
- Assert.IsType(MessageSerializer.Deserialize(@"MSH|^~\&||||||||||2.8.2||"));
+ Assert.IsType(MessageSerializer.Deserialize($"{ @"MSH|^~\&||||||||||2.8.2||" }{ Consts.LineTerminator }"));
}
///
@@ -313,7 +313,7 @@ public void Deserialize_With282Specified_ReturnsCorrectMesssageVersion()
[Fact]
public void Deserialize_With29Specified_ReturnsCorrectMesssageVersion()
{
- Assert.IsType(MessageSerializer.Deserialize(@"MSH|^~\&||||||||||2.9||"));
+ Assert.IsType(MessageSerializer.Deserialize($"{ @"MSH|^~\&||||||||||2.9||" }{ Consts.LineTerminator }"));
}
///
@@ -397,7 +397,7 @@ public void Serialize_WithThreeSegments_ReturnsCorrectlySequencedFields()
}
};
- string expected = "MSH|^~\\&|Sender 1||Receiver 1||20201202144539|||||2.9\rIN1|15|MNO Healthcare|736HB^^^DES1&UID654&Type 5~AA876^^^LLL098&UID123&Type 7\rCDM||Code 1^ABC~Code 2^ZYX\r";
+ string expected = $"MSH|^~\\&|Sender 1||Receiver 1||20201202144539|||||2.9{ Consts.LineTerminator }IN1|15|MNO Healthcare|736HB^^^DES1&UID654&Type 5~AA876^^^LLL098&UID123&Type 7{ Consts.LineTerminator }CDM||Code 1^ABC~Code 2^ZYX{ Consts.LineTerminator }";
string actual = MessageSerializer.Serialize(hl7Message);
Assert.Equal(expected, actual);