public void TryGetString_InvalidDicomFile() { var filename = Path.GetTempFileName(); using (var writer = new StreamWriter(filename)) { writer.WriteLine("Hello World!"); } var dicomToolkit = new DicomToolkit(); Assert.False(dicomToolkit.TryGetString(filename, DicomTag.SOPClassUID, out var _)); }
public void TryGetString_ValidFile() { var dicomFile = new DicomFile(); var expectedSop = DicomUIDGenerator.GenerateDerivedFromUUID(); dicomFile.Dataset.Add(DicomTag.SOPInstanceUID, expectedSop); dicomFile.FileMetaInfo.TransferSyntax = DicomTransferSyntax.ExplicitVRLittleEndian; dicomFile.FileMetaInfo.MediaStorageSOPInstanceUID = DicomUIDGenerator.GenerateDerivedFromUUID(); dicomFile.FileMetaInfo.MediaStorageSOPClassUID = DicomUIDGenerator.GenerateDerivedFromUUID(); var dicomToolkit = new DicomToolkit(); Assert.True(dicomToolkit.TryGetString(dicomFile, DicomTag.SOPInstanceUID, out var sopInstanceUId)); Assert.Equal(expectedSop.UID, sopInstanceUId); }