public async Task GivenSeriesTag_WhenReindexWithOldInstance_ThenTagValueShouldNotBeUpdated() { DicomTag tag = DicomTag.AcquisitionDeviceProcessingCode; string tagValue1 = "test1"; string tagValue2 = "test2"; string studyUid = TestUidGenerator.Generate(); string seriesUid = TestUidGenerator.Generate(); DicomDataset dataset1 = Samples.CreateRandomInstanceDataset(studyUid, seriesUid); dataset1.Add(tag, tagValue1); DicomDataset dataset2 = Samples.CreateRandomInstanceDataset(studyUid, seriesUid); dataset2.Add(tag, tagValue2); Instance instance1 = await CreateInstanceIndexAsync(dataset1); Instance instance2 = await CreateInstanceIndexAsync(dataset2); var tagStoreEntry = await AddExtendedQueryTagAsync(tag.BuildAddExtendedQueryTagEntry(level: QueryTagLevel.Series)); QueryTag queryTag = new QueryTag(tagStoreEntry); await _indexDataStore.ReindexInstanceAsync(dataset2, instance2.Watermark, new[] { queryTag }); await _indexDataStore.ReindexInstanceAsync(dataset1, instance1.Watermark, new[] { queryTag }); var row = (await _extendedQueryTagStoreTestHelper.GetExtendedQueryTagDataAsync(ExtendedQueryTagDataType.StringData, tagStoreEntry.Key, instance1.StudyKey, instance1.SeriesKey, null)).First(); Assert.Equal(tagValue2, row.TagValue); }
public async Task GivenExistingExtendedQueryTagIndexData_WhenDeleteExtendedQueryTag_ThenShouldDeleteIndexData() { DicomTag tag = DicomTag.DeviceSerialNumber; // Prepare index data DicomDataset dataset = Samples.CreateRandomInstanceDataset(); dataset.Add(tag, "123"); await AddExtendedQueryTagsAsync(new AddExtendedQueryTagEntry[] { tag.BuildAddExtendedQueryTagEntry() }); ExtendedQueryTagStoreEntry storeEntry = await _extendedQueryTagStore.GetExtendedQueryTagAsync(tag.GetPath()); QueryTag queryTag = new QueryTag(storeEntry); long watermark = await _indexDataStore.BeginCreateInstanceIndexAsync(1, dataset, new QueryTag[] { queryTag }); await _indexDataStore.EndCreateInstanceIndexAsync(1, dataset, watermark, new QueryTag[] { queryTag }); var extendedQueryTagIndexData = await _extendedQueryTagStoreTestHelper.GetExtendedQueryTagDataForTagKeyAsync(ExtendedQueryTagDataType.StringData, storeEntry.Key); Assert.NotEmpty(extendedQueryTagIndexData); // Delete tag await _extendedQueryTagStore.DeleteExtendedQueryTagAsync(storeEntry.Path, storeEntry.VR); await VerifyTagNotExistAsync(storeEntry.Path); // Verify index data is removed extendedQueryTagIndexData = await _extendedQueryTagStoreTestHelper.GetExtendedQueryTagDataForTagKeyAsync(ExtendedQueryTagDataType.StringData, storeEntry.Key); Assert.Empty(extendedQueryTagIndexData); }
public async Task GivenQueryTags_WhenGettingTagsByOperation_ThenOnlyAssignedTags() { DicomTag tag1 = DicomTag.DeviceSerialNumber; DicomTag tag2 = DicomTag.PatientAge; DicomTag tag3 = DicomTag.PatientMotherBirthName; IReadOnlyList <ExtendedQueryTagStoreEntry> actual; // Add the tags List <int> expected = (await AddExtendedQueryTagsAsync( new AddExtendedQueryTagEntry[] { tag1.BuildAddExtendedQueryTagEntry(), tag2.BuildAddExtendedQueryTagEntry(), tag3.BuildAddExtendedQueryTagEntry(), }, ready: false)).Take(2).ToList(); // Assign the first two to the operation Guid operationId = Guid.NewGuid(); actual = await _extendedQueryTagStore.AssignReindexingOperationAsync( expected, operationId, returnIfCompleted : false); Assert.True(actual.Select(x => x.Key).SequenceEqual(expected)); // Query the tags actual = await _extendedQueryTagStore.GetExtendedQueryTagsAsync(operationId); Assert.True(actual.Select(x => x.Key).SequenceEqual(expected)); }
private async Task ValidateAddNewExtendedQueryTagIndexData(QueryTagLevel level) { string studyInstanceUid = TestUidGenerator.Generate(); string seriesInstanceUid = TestUidGenerator.Generate(); string sopInstanceUid = TestUidGenerator.Generate(); DicomDataset dataset = Samples.CreateRandomInstanceDataset(studyInstanceUid, seriesInstanceUid, sopInstanceUid); DicomTag tag = DicomTag.ConversionType; string value = "SYN"; dataset.Add(tag, value); QueryTag queryTag = await AddExtendedQueryTag(tag.BuildAddExtendedQueryTagEntry(level: level)); try { long watermark = await CreateInstanceIndexAsync(dataset, new QueryTag[] { queryTag }); Instance instance = await _testHelper.GetInstanceAsync(studyInstanceUid, seriesInstanceUid, sopInstanceUid, watermark); long?seriesKey = level != QueryTagLevel.Study ? instance.SeriesKey : null; long?instanceKey = level == QueryTagLevel.Instance ? instance.InstanceKey : null; var stringRows = await _extendedQueryTagStoreTestHelper.GetExtendedQueryTagDataAsync(ExtendedQueryTagDataType.StringData, queryTag.ExtendedQueryTagStoreEntry.Key, instance.StudyKey, seriesKey, instanceKey); Assert.Single(stringRows); Assert.Equal(stringRows[0].TagValue, value); Assert.Equal(stringRows[0].Watermark, watermark); } finally { await _extendedQueryTagStore.DeleteExtendedQueryTagAsync(queryTag.ExtendedQueryTagStoreEntry.Path, queryTag.ExtendedQueryTagStoreEntry.VR); } }
public async Task GivenValidInput_WhenAddExtendedQueryTagIsInvoked_ThenShouldSucceed() { DicomTag tag = DicomTag.DeviceSerialNumber; AddExtendedQueryTagEntry entry = tag.BuildAddExtendedQueryTagEntry(); await _extendedQueryTagService.AddExtendedQueryTagAsync(new AddExtendedQueryTagEntry[] { entry }, default); _extendedQueryTagEntryValidator.ReceivedWithAnyArgs().ValidateExtendedQueryTags(default);
private async Task <int> AddTagAsync(DicomTag tag) { AddExtendedQueryTagEntry extendedQueryTagEntry = tag.BuildAddExtendedQueryTagEntry(); var list = await _extendedQueryTagStore.AddExtendedQueryTagsAsync(new AddExtendedQueryTagEntry[] { extendedQueryTagEntry }, 128); return(list[0].Key); }
public async Task GivenInstanceNotExist_WhenReindex_ThenShouldThrowException() { DicomTag tag = DicomTag.DeviceID; var tagStoreEntry = await AddExtendedQueryTagAsync(tag.BuildAddExtendedQueryTagEntry(level: QueryTagLevel.Instance)); DicomDataset dataset = Samples.CreateRandomInstanceDataset(); await Assert.ThrowsAsync <InstanceNotFoundException>(() => _indexDataStore.ReindexInstanceAsync(dataset, 0, new[] { new QueryTag(tagStoreEntry) })); }
public async Task GivenCompletedExtendedQueryTag_WhenAddExtendedQueryTag_ThenShouldThrowException() { DicomTag tag = DicomTag.DeviceSerialNumber; AddExtendedQueryTagEntry extendedQueryTagEntry = tag.BuildAddExtendedQueryTagEntry(); await AddExtendedQueryTagsAsync(new AddExtendedQueryTagEntry[] { extendedQueryTagEntry }); await Assert.ThrowsAsync <ExtendedQueryTagsAlreadyExistsException>(() => AddExtendedQueryTagsAsync(new AddExtendedQueryTagEntry[] { extendedQueryTagEntry })); }
public async Task GivenReindexingExtendedQueryTag_WhenAddExtendedQueryTag_ThenShouldThrowException() { DicomTag tag = DicomTag.DeviceSerialNumber; AddExtendedQueryTagEntry extendedQueryTagEntry = tag.BuildAddExtendedQueryTagEntry(); int key = (await AddExtendedQueryTagsAsync(new AddExtendedQueryTagEntry[] { extendedQueryTagEntry }, ready: false)).Single(); Assert.NotEmpty(await _extendedQueryTagStore.AssignReindexingOperationAsync(new int[] { key }, Guid.NewGuid())); await Assert.ThrowsAsync <ExtendedQueryTagsAlreadyExistsException>(() => AddExtendedQueryTagsAsync(new AddExtendedQueryTagEntry[] { extendedQueryTagEntry })); }
public async Task GivenValidTag_WhenGetTag_ThenShouldSucceed() { DicomTag tag = DicomTag.DeviceSerialNumber; var expected = tag.BuildAddExtendedQueryTagEntry(); IReadOnlyList <int> keys = await AddExtendedQueryTagsAsync(new AddExtendedQueryTagEntry[] { expected }, ready : true); var actual = await _extendedQueryTagStore.GetExtendedQueryTagAsync(tag.GetPath()); AssertTag(keys.Single(), expected, actual, ExtendedQueryTagStatus.Ready, operationId: null); }
public async Task GivenExistingExtendedQueryTag_WhenDeleteExtendedQueryTag_ThenTagShouldBeRemoved() { DicomTag tag = DicomTag.DeviceSerialNumber; AddExtendedQueryTagEntry extendedQueryTagEntry = tag.BuildAddExtendedQueryTagEntry(); await _extendedQueryTagStore.AddExtendedQueryTagsAsync(new AddExtendedQueryTagEntry[] { extendedQueryTagEntry }); await _extendedQueryTagStore.DeleteExtendedQueryTagAsync(extendedQueryTagEntry.Path, extendedQueryTagEntry.VR); await VerifyTagNotExist(extendedQueryTagEntry.Path); }
public async Task GivenValidExtendedQueryTags_WhenAddExtendedQueryTag_ThenTagShouldBeAdded() { DicomTag tag1 = DicomTag.DeviceSerialNumber; DicomTag tag2 = new DicomTag(0x0405, 0x1001, "PrivateCreator1"); AddExtendedQueryTagEntry extendedQueryTagEntry1 = tag1.BuildAddExtendedQueryTagEntry(); AddExtendedQueryTagEntry extendedQueryTagEntry2 = tag2.BuildAddExtendedQueryTagEntry(vr: DicomVRCode.CS); IReadOnlyList <int> keys = await AddExtendedQueryTagsAsync(new AddExtendedQueryTagEntry[] { extendedQueryTagEntry1, extendedQueryTagEntry2 }); await AssertAddedAsync(keys[0], extendedQueryTagEntry1); await AssertAddedAsync(keys[1], extendedQueryTagEntry2); }
public async Task GivenMoreThanAllowedExtendedQueryTags_WhenAddExtendedQueryTag_ThenShouldThrowException() { DicomTag tag1 = DicomTag.DeviceSerialNumber; AddExtendedQueryTagEntry extendedQueryTagEntry1 = tag1.BuildAddExtendedQueryTagEntry(); await AddExtendedQueryTagsAsync(new AddExtendedQueryTagEntry[] { extendedQueryTagEntry1 }); DicomTag tag2 = DicomTag.DeviceDescription; AddExtendedQueryTagEntry extendedQueryTagEntry2 = tag2.BuildAddExtendedQueryTagEntry(); await Assert.ThrowsAsync <ExtendedQueryTagsExceedsMaxAllowedCountException>(() => AddExtendedQueryTagsAsync(new AddExtendedQueryTagEntry[] { extendedQueryTagEntry2 }, maxAllowedCount : 1)); }
public async Task GivenPendingInstance_WhenReindex_ThenShouldThrowException() { DicomTag tag = DicomTag.DeviceDescription; var tagStoreEntry = await AddExtendedQueryTagAsync(tag.BuildAddExtendedQueryTagEntry(level: QueryTagLevel.Instance)); DicomDataset dataset = Samples.CreateRandomInstanceDataset(); long watermark = await _indexDataStore.BeginCreateInstanceIndexAsync(1, dataset); await Assert.ThrowsAsync <PendingInstanceException>(() => _indexDataStore.ReindexInstanceAsync(dataset, watermark, new[] { new QueryTag(tagStoreEntry) })); }
public async Task GivenValidExtendedQueryTag_WhenAddExtendedQueryTag_ThenTagQueryStatusShouldBeEnabled() { DicomTag tag = DicomTag.DeviceSerialNumber; AddExtendedQueryTagEntry extendedQueryTagEntry = tag.BuildAddExtendedQueryTagEntry(); await AddExtendedQueryTagsAsync(new AddExtendedQueryTagEntry[] { extendedQueryTagEntry }); var tagEntry = await _extendedQueryTagStore.GetExtendedQueryTagAsync(tag.GetPath()); Assert.Equal(QueryStatus.Enabled, tagEntry.QueryStatus); }
public async Task GivenPartiallyDeletedExtendedQueryTag_WhenDeleteExtendedQueryTag_ThenTagShouldBeRemoved() { DicomTag tag = DicomTag.DeviceSerialNumber; AddExtendedQueryTagEntry extendedQueryTagEntry = tag.BuildAddExtendedQueryTagEntry(); IReadOnlyList <int> keys = await AddExtendedQueryTagsAsync(new AddExtendedQueryTagEntry[] { extendedQueryTagEntry }); await _extendedQueryTagStoreTestHelper.SetTagStatusAsync(keys.Single(), ExtendedQueryTagStatus.Deleting); await _extendedQueryTagStore.DeleteExtendedQueryTagAsync(extendedQueryTagEntry.Path, extendedQueryTagEntry.VR); await VerifyTagNotExistAsync(extendedQueryTagEntry.Path); }
public async Task GivenValidTagWithOperation_WhenGetTag_ThenShouldSucceedAndIncludeId() { Guid id = Guid.NewGuid(); DicomTag tag = DicomTag.AcquisitionDateTime; var expected = tag.BuildAddExtendedQueryTagEntry(); IReadOnlyList <int> keys = await AddExtendedQueryTagsAsync(new AddExtendedQueryTagEntry[] { expected }, ready : false); await _extendedQueryTagStore.AssignReindexingOperationAsync(keys, id); var actual = await _extendedQueryTagStore.GetExtendedQueryTagAsync(tag.GetPath()); AssertTag(keys.Single(), expected, actual, ExtendedQueryTagStatus.Adding, operationId: id); }
private async Task ValidateUpdateExistingExtendedQueryTagIndexData(QueryTagLevel level) { if (level == QueryTagLevel.Instance) { throw new System.ArgumentException("Update value on instance level is not valid case."); } string studyInstanceUid = TestUidGenerator.Generate(); string seriesInstanceUid = TestUidGenerator.Generate(); string sopInstanceUid = TestUidGenerator.Generate(); DicomDataset dataset = Samples.CreateRandomInstanceDataset(studyInstanceUid, seriesInstanceUid, sopInstanceUid); DicomTag tag = DicomTag.ConversionType; string value = "SYN"; dataset.Add(tag, value); QueryTag queryTag = await AddExtendedQueryTag(tag.BuildAddExtendedQueryTagEntry(level: level)); try { // index extended query tags await CreateInstanceIndexAsync(dataset, new QueryTag[] { queryTag }); // update value = "NEWSYN"; dataset.AddOrUpdate(tag, value); sopInstanceUid = TestUidGenerator.Generate(); dataset.AddOrUpdate(DicomTag.SOPInstanceUID, sopInstanceUid); if (level == QueryTagLevel.Study) { seriesInstanceUid = TestUidGenerator.Generate(); dataset.AddOrUpdate(DicomTag.SeriesInstanceUID, seriesInstanceUid); } // index new instance long watermark = await CreateInstanceIndexAsync(dataset, new QueryTag[] { queryTag }); Instance instance = await _testHelper.GetInstanceAsync(studyInstanceUid, seriesInstanceUid, sopInstanceUid, watermark); long?seriesKey = level != QueryTagLevel.Study ? instance.SeriesKey : null; var stringRows = await _extendedQueryTagStoreTestHelper.GetExtendedQueryTagDataAsync(ExtendedQueryTagDataType.StringData, queryTag.ExtendedQueryTagStoreEntry.Key, instance.StudyKey, seriesKey); Assert.Single(stringRows); Assert.Equal(stringRows[0].TagValue, value); Assert.Equal(stringRows[0].Watermark, watermark); } finally { await _extendedQueryTagStore.DeleteExtendedQueryTagAsync(queryTag.ExtendedQueryTagStoreEntry.Path, queryTag.ExtendedQueryTagStoreEntry.VR); } }
public async Task GivenExistingExtendedQueryTag_WhenAddExtendedQueryTag_ThenShouldThrowException() { DicomTag tag = DicomTag.DeviceSerialNumber; AddExtendedQueryTagEntry extendedQueryTagEntry = tag.BuildAddExtendedQueryTagEntry(); await _extendedQueryTagStore.AddExtendedQueryTagsAsync(new AddExtendedQueryTagEntry[] { extendedQueryTagEntry }); try { await Assert.ThrowsAsync <ExtendedQueryTagsAlreadyExistsException>(() => _extendedQueryTagStore.AddExtendedQueryTagsAsync(new AddExtendedQueryTagEntry[] { extendedQueryTagEntry })); } finally { await _extendedQueryTagStore.DeleteExtendedQueryTagAsync(extendedQueryTagEntry.Path, extendedQueryTagEntry.VR); } }
public async Task GivenInvalidInput_WhenAddingExtendedQueryTag_ThenStopAfterValidation() { DicomTag tag = DicomTag.DeviceSerialNumber; AddExtendedQueryTagEntry entry = tag.BuildAddExtendedQueryTagEntry(); var exception = new ExtendedQueryTagEntryValidationException(string.Empty); var input = new AddExtendedQueryTagEntry[] { entry }; _extendedQueryTagEntryValidator.WhenForAnyArgs(v => v.ValidateExtendedQueryTags(input)).Throw(exception); await Assert.ThrowsAsync <ExtendedQueryTagEntryValidationException>( () => _extendedQueryTagService.AddExtendedQueryTagsAsync(input, _tokenSource.Token)); _extendedQueryTagEntryValidator.Received(1).ValidateExtendedQueryTags(input); await _client.DidNotReceiveWithAnyArgs().StartReindexingInstancesAsync(default, default);
public async Task GivenStudyTag_WhenReindexWithNewInstance_ThenTagValueShouldBeUpdated() { DicomTag tag = DicomTag.DeviceSerialNumber; string tagValue1 = "test1"; string tagValue2 = "test2"; string tagValue3 = "test3"; string studyUid = TestUidGenerator.Generate(); DicomDataset dataset1 = Samples.CreateRandomInstanceDataset(studyUid); dataset1.Add(tag, tagValue1); DicomDataset dataset2 = Samples.CreateRandomInstanceDataset(studyUid); dataset2.Add(tag, tagValue2); DicomDataset dataset3 = Samples.CreateRandomInstanceDataset(studyUid); dataset3.Add(tag, tagValue3); Instance instance1 = await CreateInstanceIndexAsync(dataset1); Instance instance2 = await CreateInstanceIndexAsync(dataset2); Instance instance3 = await CreateInstanceIndexAsync(dataset3); var tagStoreEntry = await AddExtendedQueryTagAsync(tag.BuildAddExtendedQueryTagEntry(level: QueryTagLevel.Study)); QueryTag queryTag = new QueryTag(tagStoreEntry); // Simulate re-indexing, which may re-index an instance which may re-index // the instances for a particular study or series out-of-order await _indexDataStore.ReindexInstanceAsync(dataset2, instance2.Watermark, new[] { queryTag }); ExtendedQueryTagDataRow row = (await _extendedQueryTagStoreTestHelper.GetExtendedQueryTagDataAsync(ExtendedQueryTagDataType.StringData, tagStoreEntry.Key, instance1.StudyKey, null, null)).Single(); Assert.Equal(tagValue2, row.TagValue); // Added await _indexDataStore.ReindexInstanceAsync(dataset3, instance3.Watermark, new[] { queryTag }); row = (await _extendedQueryTagStoreTestHelper.GetExtendedQueryTagDataAsync(ExtendedQueryTagDataType.StringData, tagStoreEntry.Key, instance1.StudyKey, null, null)).Single(); Assert.Equal(tagValue3, row.TagValue); // Overwrite await _indexDataStore.ReindexInstanceAsync(dataset1, instance1.Watermark, new[] { queryTag }); row = (await _extendedQueryTagStoreTestHelper.GetExtendedQueryTagDataAsync(ExtendedQueryTagDataType.StringData, tagStoreEntry.Key, instance1.StudyKey, null, null)).Single(); Assert.Equal(tagValue3, row.TagValue); // Do not overwrite }
public async Task GivenInstanceTag_WhenReindexWithIndexedInstance_ThenTagValueShouldNotBeUpdated() { DicomTag tag = DicomTag.DeviceLabel; string tagValue = "test"; var tagStoreEntry = await AddExtendedQueryTagAsync(tag.BuildAddExtendedQueryTagEntry(level: QueryTagLevel.Instance)); DicomDataset dataset = Samples.CreateRandomInstanceDataset(); dataset.Add(tag, tagValue); var instance = await CreateInstanceIndexAsync(dataset); await _indexDataStore.ReindexInstanceAsync(dataset, instance.Watermark, new[] { new QueryTag(tagStoreEntry) }); var row = (await _extendedQueryTagStoreTestHelper.GetExtendedQueryTagDataAsync(ExtendedQueryTagDataType.StringData, tagStoreEntry.Key, instance.StudyKey, instance.SeriesKey, instance.InstanceKey)).First(); Assert.Equal(tagValue, row.TagValue); }
public async Task GivenUnfinishedExistingExtendedQueryTag_WhenAddExtendedQueryTag_ThenTagShouldBeAdded() { DicomTag tag = DicomTag.PatientAge; AddExtendedQueryTagEntry extendedQueryTagEntry = tag.BuildAddExtendedQueryTagEntry(); // Add and verify the tag was added int oldKey = (await AddExtendedQueryTagsAsync(new AddExtendedQueryTagEntry[] { extendedQueryTagEntry }, ready: false)).Single(); await AssertAddedAsync(oldKey, extendedQueryTagEntry, ExtendedQueryTagStatus.Adding); // Add the tag again before it can be associated with a re-indexing operation int newKey = (await AddExtendedQueryTagsAsync(new AddExtendedQueryTagEntry[] { extendedQueryTagEntry }, ready: false)).Single(); await AssertAddedAsync(newKey, extendedQueryTagEntry, ExtendedQueryTagStatus.Adding); Assert.NotEqual(oldKey, newKey); }
public async Task GivenQueryTags_WhenAssigningReindexingOperation_ThenOnlyReturnDesiredTags() { DicomTag tag1 = DicomTag.DeviceSerialNumber; DicomTag tag2 = DicomTag.PatientAge; DicomTag tag3 = DicomTag.PatientMotherBirthName; AddExtendedQueryTagEntry extendedQueryTagEntry1 = tag1.BuildAddExtendedQueryTagEntry(); AddExtendedQueryTagEntry extendedQueryTagEntry2 = tag2.BuildAddExtendedQueryTagEntry(); AddExtendedQueryTagEntry extendedQueryTagEntry3 = tag3.BuildAddExtendedQueryTagEntry(); List <int> keys = (await AddExtendedQueryTagsAsync(new AddExtendedQueryTagEntry[] { extendedQueryTagEntry1, extendedQueryTagEntry2 }, ready: false)) .Concat(await AddExtendedQueryTagsAsync(new AddExtendedQueryTagEntry[] { extendedQueryTagEntry3 }, ready: true)) .ToList(); // Only return tags that are being indexed IReadOnlyList <ExtendedQueryTagStoreEntry> actual = await _extendedQueryTagStore.AssignReindexingOperationAsync(keys, Guid.NewGuid(), returnIfCompleted : false); Assert.True(actual.Select(x => x.Key).SequenceEqual(keys.Take(2))); }
public async Task GivenValidTags_WhenGetTagWithPagination_ThenShouldSucceed() { DicomTag tag1 = DicomTag.DeviceSerialNumber; DicomTag tag2 = DicomTag.DeviceID; DicomTag tag3 = DicomTag.PatientAge; var addEntry1 = tag1.BuildAddExtendedQueryTagEntry(); var addEntry2 = tag2.BuildAddExtendedQueryTagEntry(); var addEntry3 = tag3.BuildAddExtendedQueryTagEntry(); var addEntries = new AddExtendedQueryTagEntry[] { addEntry1, addEntry2, addEntry3 }; await AddExtendedQueryTagsAsync(addEntries, ready : true); int offset = 0; int limit = 1; List <ExtendedQueryTagStoreEntry> entries = new List <ExtendedQueryTagStoreEntry>(); do { var tagEntries = await _extendedQueryTagStore.GetExtendedQueryTagsAsync(limit, offset); if (tagEntries.Count == 0) { break; } else { entries.AddRange(tagEntries); offset += limit; } } while (true); Assert.Equal(3, entries.Count); for (int i = 0; i < addEntries.Length; i++) { Assert.Equal(addEntries[i].Path, entries[i].Path); Assert.Equal(addEntries[i].Level, entries[i].Level); Assert.Equal(addEntries[i].PrivateCreator, entries[i].PrivateCreator); Assert.Equal(addEntries[i].VR, entries[i].VR); Assert.Equal(ExtendedQueryTagStatus.Ready, entries[i].Status); Assert.Equal(QueryStatus.Enabled, entries[i].QueryStatus); } }
public async Task GivenValidExtendedQueryTags_WhenGettingExtendedQueryTagsByKey_ThenOnlyPresentTagsAreReturned() { Guid id = Guid.NewGuid(); DicomTag tag1 = DicomTag.DeviceSerialNumber; DicomTag tag2 = new DicomTag(0x0405, 0x1001, "PrivateCreator1"); AddExtendedQueryTagEntry expected1 = tag1.BuildAddExtendedQueryTagEntry(); AddExtendedQueryTagEntry expected2 = tag2.BuildAddExtendedQueryTagEntry(vr: DicomVRCode.CS); int key1 = (await AddExtendedQueryTagsAsync(new AddExtendedQueryTagEntry[] { expected1 }, ready: false)).Single(); int key2 = (await AddExtendedQueryTagsAsync(new AddExtendedQueryTagEntry[] { expected2 }, ready: true)).Single(); await _extendedQueryTagStore.AssignReindexingOperationAsync(new List <int> { key1 }, id); // Fetch the newly added keys (and pass 1 more key we know doesn't have a corresponding entry) IReadOnlyList <ExtendedQueryTagStoreJoinEntry> actual = await _extendedQueryTagStore.GetExtendedQueryTagsAsync(new int[] { key1, key2, key2 + 1 }); Assert.Equal(2, actual.Count); AssertTag(key1, expected1, actual[0], ExtendedQueryTagStatus.Adding, operationId: id); AssertTag(key2, expected2, actual[1], ExtendedQueryTagStatus.Ready); }
public async Task GivenValidExtendedQueryTags_WhenAddExtendedQueryTag_ThenTagShouldBeAdded() { DicomTag tag1 = DicomTag.DeviceSerialNumber; DicomTag tag2 = new DicomTag(0x0405, 0x1001, "PrivateCreator1"); AddExtendedQueryTagEntry extendedQueryTagEntry1 = tag1.BuildAddExtendedQueryTagEntry(); AddExtendedQueryTagEntry extendedQueryTagEntry2 = tag2.BuildAddExtendedQueryTagEntry(vr: DicomVRCode.CS); await _extendedQueryTagStore.AddExtendedQueryTagsAsync(new AddExtendedQueryTagEntry[] { extendedQueryTagEntry1, extendedQueryTagEntry2 }); try { await VerifyTagIsAdded(extendedQueryTagEntry1); await VerifyTagIsAdded(extendedQueryTagEntry2); } finally { // Delete extended query tag await _extendedQueryTagStore.DeleteExtendedQueryTagAsync(extendedQueryTagEntry1.Path, extendedQueryTagEntry1.VR); await _extendedQueryTagStore.DeleteExtendedQueryTagAsync(extendedQueryTagEntry2.Path, extendedQueryTagEntry2.VR); } }
public async Task GivenValidTag_WhenUpdateTagQueryStatus_ThenShouldSucceed() { DicomTag tag = DicomTag.DeviceSerialNumber; var addEntry = tag.BuildAddExtendedQueryTagEntry(); IReadOnlyList <int> keys = await AddExtendedQueryTagsAsync(new AddExtendedQueryTagEntry[] { addEntry }, ready : false); var updateEntry = await _extendedQueryTagStore.UpdateQueryStatusAsync(tag.GetPath(), QueryStatus.Disabled); AssertTag(keys.Single(), addEntry, updateEntry, ExtendedQueryTagStatus.Adding, queryStatus: QueryStatus.Disabled); updateEntry = await _extendedQueryTagStore.UpdateQueryStatusAsync(tag.GetPath(), QueryStatus.Enabled); AssertTag(keys.Single(), addEntry, updateEntry, ExtendedQueryTagStatus.Adding, queryStatus: QueryStatus.Enabled); Guid id = Guid.NewGuid(); await _extendedQueryTagStore.AssignReindexingOperationAsync(keys, id); updateEntry = await _extendedQueryTagStore.UpdateQueryStatusAsync(tag.GetPath(), QueryStatus.Enabled); AssertTag(keys.Single(), addEntry, updateEntry, ExtendedQueryTagStatus.Adding, queryStatus: QueryStatus.Enabled, operationId: id); }