Skip to content

Commit

Permalink
Amend LegacyPipeParserBadInputTest based on these changes and convers…
Browse files Browse the repository at this point in the history
…ation with @JlKmn
  • Loading branch information
milkshakeuk committed Apr 14, 2021
1 parent 7fd168b commit 35c808a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions tests/NHapi.Base.NUnit/Model/AbstractGroupTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void AddNonstandardSegment_WithKnownType_AllowsReturnOfSegment()
var result = message.GetStructure(segmentToTest, 1);

// Assert
Assert.AreEqual(expectedSegmentType.Name, result.GetType().Name);
Assert.AreEqual(expectedSegmentType, result.GetType());
}

[Test]
Expand All @@ -40,7 +40,7 @@ public void AddNonstandardSegment_WithUnknownType_AllowsReturnOfSegment()
var result = message.GetStructure(segmentToTest);

// Assert
Assert.AreEqual(expectedSegmentType.Name, result.GetType().Name);
Assert.AreEqual(expectedSegmentType, result.GetType());
}

[Test]
Expand Down
6 changes: 3 additions & 3 deletions tests/NHapi.Base.NUnit/Model/AbstractSegmentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public void TestEnsureEnoughFields()
msh.GetField(n + 3, 0);

// Assert
Assert.AreEqual(nameof(Varies), msh.GetField(n + 1, 0).GetType().Name);
Assert.AreEqual(nameof(Varies), msh.GetField(n + 2, 0).GetType().Name);
Assert.AreEqual(nameof(Varies), msh.GetField(n + 3, 0).GetType().Name);
Assert.AreEqual(typeof(Varies), msh.GetField(n + 1, 0).GetType());
Assert.AreEqual(typeof(Varies), msh.GetField(n + 2, 0).GetType());
Assert.AreEqual(typeof(Varies), msh.GetField(n + 3, 0).GetType());
}

[Test]
Expand Down
15 changes: 7 additions & 8 deletions tests/NHapi.NUnit/Parser/LegacyPipeParserBadInputTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,17 @@ public class LegacyPipeParserBadInputTests
private const string SO = "TestData/BadInputs/stackoverflow1";
private const string SO2 = "TestData/BadInputs/stackoverflow2";

[TestCase(AOOR1)]
[TestCase(SYS1)]
[TestCase(NULLREF1)]
[TestCase(IOOR1)]
[TestCase(SYS2)]
public void TestBadInputsThrowHL7Exception(string path)
[TestCase(AOOR1, typeof(EncodingNotSupportedException))]
[TestCase(NULLREF1, typeof(EncodingNotSupportedException))]
[TestCase(IOOR1, typeof(HL7Exception))]
public void TestBadInputsThrowException(string path, Type expectedExceptionType)
{
// Arrange
var parser = new LegacyPipeParser();
var text = File.ReadAllText(path);

// Act / Assert
var exception = Assert.Throws<HL7Exception>(
() => parser.Parse(text));
var exception = Assert.Throws(expectedExceptionType, () => parser.Parse(text));

// Write exception details to console
Console.WriteLine(exception);
Expand All @@ -45,6 +42,8 @@ public void TestBadInputsThrowHL7Exception(string path)
[TestCase(HANG1)]
[TestCase(SO)]
[TestCase(SO2)]
[TestCase(SYS1)]
[TestCase(SYS2)]
public void TestBadInputsAreHandledGracefully(string path)
{
// Arrange
Expand Down

0 comments on commit 35c808a

Please sign in to comment.