Skip to content

Commit

Permalink
More unit test fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
jas88 committed Mar 18, 2022
1 parent dc9bf63 commit 34f4667
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
3 changes: 1 addition & 2 deletions DicomTypeTranslation.Tests/BsonTranslationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public void DicomToBson_TranslateEmptyElements_TagsRetainedValuesNull()
[Test]
public void DicomToBson_TranslateNormalDataset_DoesNotThrow()
{
DicomDataset ds = TranslationTestHelpers.BuildVrDataset();
Assert.DoesNotThrow(() => DicomTypeTranslaterReader.BuildBsonDocument(ds));
Assert.DoesNotThrow(() => DicomTypeTranslaterReader.BuildBsonDocument(TranslationTestHelpers.BuildVrDataset()));
}

[Test]
Expand Down
16 changes: 8 additions & 8 deletions DicomTypeTranslation.Tests/DicomTypeTranslatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void TestSequenceConversion()
Assert.AreEqual(2, asArray[0].Count);

Assert.AreEqual("short desc", asArray[0][DicomTag.SpecimenShortDescription]);
Assert.AreEqual("99Y", asArray[0][DicomTag.PatientAge]);
Assert.AreEqual("099Y", asArray[0][DicomTag.PatientAge]);
}

[Test]
Expand Down Expand Up @@ -97,7 +97,7 @@ public void TestMultipleElementSequences()
// Hemodynamic Waveform Storage class UID, plus counter
{DicomTag.ReferencedSOPClassUID, $"1.2.840.10008.5.1.4.1.1.9.2.1.{(i + 1)}" },
// Truncated example instance UID from dicom.innolytics.com, plus counter
{DicomTag.ReferencedSOPInstanceUID, $"1.3.6.1.4.1.14519.5.2.1.7695.2311.916784049-{(i + 1)}" }
{DicomTag.ReferencedSOPInstanceUID, $"1.3.6.1.4.1.14519.5.2.1.7695.2311.916784049.{(i + 1)}" }
});
}

Expand Down Expand Up @@ -209,12 +209,12 @@ public void PrintValueTypesForVrs()
[Test]
public void TestGetCSharpValueThrowsException()
{
var ds = new DicomDataset
{
new DicomDecimalString(DicomTag.SelectorDSValue, "aaahhhhh")
};

Assert.Throws<FellowOakDicom.DicomValidationException>(() => DicomTypeTranslaterReader.GetCSharpValue(ds, DicomTag.SelectorDSValue));
Assert.Throws<FellowOakDicom.DicomValidationException>(() => DicomTypeTranslaterReader.GetCSharpValue(
new DicomDataset
{
new DicomDecimalString(DicomTag.SelectorDSValue, "aaahhhhh")
},
DicomTag.SelectorDSValue));
}


Expand Down
6 changes: 3 additions & 3 deletions DicomTypeTranslation.Tests/Helpers/TranslationTestHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static DicomDataset BuildVrDataset(DicomVR singleVr = null)
var ds = new DicomDataset
{
new DicomApplicationEntity(DicomTag.RetrieveAETitle, "AppEntity-1", "AppEntity-2"),
new DicomAgeString(DicomTag.PatientAge, "34y", "32y"),
new DicomAgeString(DicomTag.PatientAge, "034y", "032y"),
new DicomAttributeTag(DicomTag.SelectorATValue, DicomTag.SOPInstanceUID, DicomTag.SeriesInstanceUID),
new DicomCodeString(DicomTag.QualityControlImage, "FOOBAR", "OOFRAB"),
new DicomDate(DicomTag.AcquisitionDate, "20000229", "20180401"),
Expand Down Expand Up @@ -54,7 +54,7 @@ public static DicomDataset BuildVrDataset(DicomVR singleVr = null)
}),
new DicomSignedShort(DicomTag.SelectorSSValue, 0, short.MinValue, short.MaxValue),
new DicomShortText(DicomTag.SelectorSTValue, "Short\\Text\\Backslashes should be ok: \\\\\\"),
new DicomSignedVeryLong(DicomTag.SelectorSVValue,0), // NOTE(rkm 2020-03-25) No tags actually have this VR yet! JS 2022-03-18 there are now...
new DicomSignedVeryLong(DicomTag.SelectorSVValue,1,7), // NOTE(rkm 2020-03-25) No tags actually have this VR yet! JS 2022-03-18 there are now...
new DicomTime(DicomTag.SelectorTMValue, "123456", "235959"),
new DicomUnlimitedCharacters(DicomTag.SelectorUCValue, "UnlimitedCharacters-1"),
new DicomUniqueIdentifier(DicomTag.SelectorUIValue, "1.2.3.4", "5.6.7.8"),
Expand All @@ -63,7 +63,7 @@ public static DicomDataset BuildVrDataset(DicomVR singleVr = null)
new DicomUniversalResource(DicomTag.URNCodeValue, "http://example.com?q=1"),
new DicomUnsignedShort(DicomTag.SelectorUSValue, 0, 1, ushort.MaxValue),
new DicomUnlimitedText(DicomTag.SelectorUTValue, "unlimited!"),
new DicomUnsignedVeryLong(DicomTag.SelectorUVValue,0), // NOTE(rkm 2020-03-25) No tags actually have this VR yet! JS 2022-03-18 there are now...
new DicomUnsignedVeryLong(DicomTag.SelectorUVValue,new UInt64[]{1}), // NOTE(rkm 2020-03-25) No tags actually have this VR yet! JS 2022-03-18 there are now...
};

if (singleVr != null)
Expand Down

0 comments on commit 34f4667

Please sign in to comment.