public void GivenValidAndInvalidTags_WhenValidating_ThenShouldThrowException() { CustomTagEntry invalidEntry = DicomTag.PatientName.BuildCustomTagEntry(); CustomTagEntry validEntry = DicomTag.DeviceSerialNumber.BuildCustomTagEntry(); Assert.Throws <CustomTagEntryValidationException>(() => _customTagEntryValidator.ValidateCustomTags(new CustomTagEntry[] { validEntry, invalidEntry })); }
public async Task GivenValidInput_WhenAddCustomTagIsInvoked_ThenShouldSucceed() { DicomTag tag = DicomTag.DeviceSerialNumber; CustomTagEntry entry = tag.BuildCustomTagEntry(); await _customTagService.AddCustomTagAsync(new CustomTagEntry[] { entry }, default); _customTagEntryValidator.ReceivedWithAnyArgs().ValidateCustomTags(default);
/// <summary> /// Normalize custom tag entry before saving to CustomTagStore. /// </summary> /// <param name="customTagEntry">The custom tag entry.</param> /// <returns>Normalize custom tag entry.</returns> public static CustomTagEntry Normalize(this CustomTagEntry customTagEntry) { DicomTagParser dicomTagParser = new DicomTagParser(); DicomTag[] tags; if (!dicomTagParser.TryParse(customTagEntry.Path, out tags, supportMultiple: false)) { // not a valid dicom tag path throw new CustomTagEntryValidationException( string.Format(CultureInfo.InvariantCulture, DicomCoreResource.InvalidCustomTag, customTagEntry)); } DicomTag tag = tags[0]; string path = tag.GetPath(); string vr = customTagEntry.VR; // when VR is not specified for standard tag, if (!tag.IsPrivate && tag.DictionaryEntry != DicomDictionary.UnknownTag) { if (string.IsNullOrWhiteSpace(vr)) { vr = tag.GetDefaultVR()?.Code; } } vr = vr.ToUpperInvariant(); return(new CustomTagEntry(path, vr, customTagEntry.Level, customTagEntry.Status)); }
public void GivenValidCustomTagEntry_WhenFormalizing_ThenShouldReturnSameEntry(CustomTagEntry entry) { CustomTagEntry normalized = entry.Normalize(); Assert.Equal(entry.Path, normalized.Path); Assert.Equal(entry.VR, normalized.VR); Assert.Equal(entry.Level, normalized.Level); }
public void GivenStandardTagWithoutVR_WhenFormalizing_ThenVRShouldBeFilled(string vr) { DicomTag tag = DicomTag.DeviceSerialNumber; CustomTagEntry entry = new CustomTagEntry(tag.GetPath(), vr, CustomTagLevel.Instance, CustomTagStatus.Added); CustomTagEntry normalized = entry.Normalize(); Assert.Equal(tag.GetDefaultVR().Code, normalized.VR); }
public void GivenVROfLowerCase_WhenFormalizing_ThenVRShouldBeUpperCase() { DicomTag tag = DicomTag.DeviceLabel; CustomTagEntry entry = new CustomTagEntry(tag.GetPath(), tag.GetDefaultVR().Code.ToLowerInvariant(), CustomTagLevel.Instance, CustomTagStatus.Added); CustomTagEntry normalized = entry.Normalize(); Assert.Equal(entry.VR.ToUpperInvariant(), normalized.VR); }
public void GivenStandardTagAsKeyword_WhenFormalizing_ThenVRShouldBeFilled() { DicomTag tag = DicomTag.DeviceSerialNumber; CustomTagEntry entry = new CustomTagEntry(path: tag.DictionaryEntry.Keyword, tag.GetDefaultVR().Code, CustomTagLevel.Instance, CustomTagStatus.Added); string expectedPath = tag.GetPath(); CustomTagEntry normalized = entry.Normalize(); Assert.Equal(normalized.Path, expectedPath); }
public void GivenStandardTagWithVR_WhenFormalizing_ThenVRShouldNotBeUpdated() { DicomTag tag = DicomTag.DeviceSerialNumber; string vr = DicomVR.CS.Code; CustomTagEntry entry = new CustomTagEntry(tag.GetPath(), vr, CustomTagLevel.Instance, CustomTagStatus.Added); CustomTagEntry normalized = entry.Normalize(); Assert.Equal(vr, normalized.VR); }
[InlineData("12051003", DicomVRCode.OB)] // private tag public void GivenUnsupportedVR_WhenValidating_ThenShouldThrowException(string path, string vr) { CustomTagEntry entry = CreateCustomTagEntry(path, vr); Assert.Throws <CustomTagEntryValidationException>(() => { _customTagEntryValidator.ValidateCustomTags(new CustomTagEntry[] { entry }); }); }
public GetCustomTagResponse(CustomTagEntry customTagEntry) { CustomTag = customTagEntry; }
public void GivenPrivateTagWithVR_WhenValidating_ThenShouldSucceed() { CustomTagEntry entry = CreateCustomTagEntry("12051003", DicomVRCode.AE); _customTagEntryValidator.ValidateCustomTags(new CustomTagEntry[] { entry }); }
public void GivenInvalidTag_WhenValidating_ThenShouldThrowException(string path) { CustomTagEntry entry = CreateCustomTagEntry(path, DicomVRCode.AE); Assert.Throws <CustomTagEntryValidationException>(() => { _customTagEntryValidator.ValidateCustomTags(new CustomTagEntry[] { entry }); }); }
public void GivenDuplicatedTag_WhenValidating_ThenShouldThrowException() { CustomTagEntry entry = DicomTag.PatientName.BuildCustomTagEntry(); Assert.Throws <CustomTagEntryValidationException>(() => _customTagEntryValidator.ValidateCustomTags(new CustomTagEntry[] { entry, entry })); }
public void GivenPrivateTagWithoutVR_WhenValidating_ThenShouldThrowException() { CustomTagEntry entry = CreateCustomTagEntry("12051003", string.Empty); Assert.Throws <CustomTagEntryValidationException>(() => _customTagEntryValidator.ValidateCustomTags(new CustomTagEntry[] { entry })); }
public void GivenValidVR_WhenValidating_ThenShouldSucceed(string vr) { CustomTagEntry entry = CreateCustomTagEntry(DicomTag.DeviceSerialNumber.GetPath(), vr); _customTagEntryValidator.ValidateCustomTags(new CustomTagEntry[] { entry }); }
public void GivenStandardTagWithoutVR_WhenValidating_ThenShouldSucceed(string vr) { CustomTagEntry entry = new CustomTagEntry(DicomTag.DeviceSerialNumber.GetPath(), vr, CustomTagLevel.Instance); _customTagEntryValidator.ValidateCustomTags(new CustomTagEntry[] { entry }); }
[InlineData("CS")] // expected vr should be LO. CS is not acceptable public void GivenInvalidVR_WhenValidating_ThenShouldThrowException(string vr) { CustomTagEntry entry = CreateCustomTagEntry(DicomTag.DeviceSerialNumber.GetPath(), vr); Assert.Throws <CustomTagEntryValidationException>(() => { _customTagEntryValidator.ValidateCustomTags(new CustomTagEntry[] { entry }); }); }
public void GivenValidTag_WhenValidating_ThenShouldSucceed(string path) { CustomTagEntry entry = CreateCustomTagEntry(path, DicomVRCode.DS); _customTagEntryValidator.ValidateCustomTags(new CustomTagEntry[] { entry }); }