예제 #1
0
        public async Task GivenNoStoredInstances_WhenRetrieveRequestForStudy_ThenNotFoundIsThrown()
        {
            _instanceStore.GetInstanceIdentifiersInStudyAsync(_studyInstanceUid).Returns(new List <VersionedInstanceIdentifier>());

            await Assert.ThrowsAsync <InstanceNotFoundException>(() => _retrieveResourceService.GetInstanceResourceAsync(
                                                                     new RetrieveResourceRequest(_studyInstanceUid, new[] { AcceptHeaderHelpers.CreateAcceptHeaderForGetStudy() }),
                                                                     DefaultCancellationToken));
        }
예제 #2
0
        private List <DicomDataset> SetupDatasetList(ResourceType resourceType, int partitionKey = DefaultPartition.Key)
        {
            DicomDataset dicomDataset1 = new DicomDataset();
            DicomDataset dicomDataset2 = new DicomDataset();

            switch (resourceType)
            {
            case ResourceType.Study:
                dicomDataset1 = CreateValidMetadataDataset(_studyInstanceUid, TestUidGenerator.Generate(), TestUidGenerator.Generate());
                dicomDataset2 = CreateValidMetadataDataset(_studyInstanceUid, TestUidGenerator.Generate(), TestUidGenerator.Generate());

                _instanceStore.GetInstanceIdentifiersInStudyAsync(partitionKey, _studyInstanceUid, DefaultCancellationToken).Returns(new List <VersionedInstanceIdentifier>()
                {
                    dicomDataset1.ToVersionedInstanceIdentifier(version: 0),
                    dicomDataset2.ToVersionedInstanceIdentifier(version: 1),
                });
                break;

            case ResourceType.Series:
                dicomDataset1 = CreateValidMetadataDataset(_studyInstanceUid, _seriesInstanceUid, TestUidGenerator.Generate());
                dicomDataset2 = CreateValidMetadataDataset(_studyInstanceUid, _seriesInstanceUid, TestUidGenerator.Generate());

                _instanceStore.GetInstanceIdentifiersInSeriesAsync(partitionKey, _studyInstanceUid, _seriesInstanceUid, DefaultCancellationToken).Returns(new List <VersionedInstanceIdentifier>()
                {
                    dicomDataset1.ToVersionedInstanceIdentifier(version: 0),
                    dicomDataset2.ToVersionedInstanceIdentifier(version: 1),
                });
                break;
            }

            return(new List <DicomDataset> {
                dicomDataset1, dicomDataset2
            });
        }
        private List <VersionedInstanceIdentifier> SetupInstanceIdentifiersList(ResourceType resourceType)
        {
            var dicomInstanceIdentifiersList = new List <VersionedInstanceIdentifier>();

            switch (resourceType)
            {
            case ResourceType.Study:
                dicomInstanceIdentifiersList.Add(new VersionedInstanceIdentifier(_studyInstanceUid, TestUidGenerator.Generate(), TestUidGenerator.Generate(), version: 0));
                dicomInstanceIdentifiersList.Add(new VersionedInstanceIdentifier(_studyInstanceUid, TestUidGenerator.Generate(), TestUidGenerator.Generate(), version: 1));
                _instanceStore.GetInstanceIdentifiersInStudyAsync(_studyInstanceUid, DefaultCancellationToken).Returns(dicomInstanceIdentifiersList);
                break;

            case ResourceType.Series:
                dicomInstanceIdentifiersList.Add(new VersionedInstanceIdentifier(_studyInstanceUid, _seriesInstanceUid, TestUidGenerator.Generate(), version: 0));
                dicomInstanceIdentifiersList.Add(new VersionedInstanceIdentifier(_studyInstanceUid, _seriesInstanceUid, TestUidGenerator.Generate(), version: 1));
                _instanceStore.GetInstanceIdentifiersInSeriesAsync(_studyInstanceUid, _seriesInstanceUid, DefaultCancellationToken).Returns(dicomInstanceIdentifiersList);
                break;

            case ResourceType.Instance:
                dicomInstanceIdentifiersList.Add(new VersionedInstanceIdentifier(_studyInstanceUid, _seriesInstanceUid, _sopInstanceUid, version: 0));
                _instanceStore.GetInstanceIdentifierAsync(_studyInstanceUid, _seriesInstanceUid, _sopInstanceUid, DefaultCancellationToken).Returns(dicomInstanceIdentifiersList);
                break;
            }

            return(dicomInstanceIdentifiersList);
        }
        public static async Task <IEnumerable <VersionedInstanceIdentifier> > GetInstancesToRetrieve(
            this IInstanceStore instanceStore,
            ResourceType resourceType,
            int partitionKey,
            string studyInstanceUid,
            string seriesInstanceUid,
            string sopInstanceUid,
            CancellationToken cancellationToken)
        {
            EnsureArg.IsNotNull(instanceStore, nameof(instanceStore));

            IEnumerable <VersionedInstanceIdentifier> instancesToRetrieve = Enumerable.Empty <VersionedInstanceIdentifier>();

            switch (resourceType)
            {
            case ResourceType.Frames:
            case ResourceType.Instance:
                instancesToRetrieve = await instanceStore.GetInstanceIdentifierAsync(
                    partitionKey,
                    studyInstanceUid,
                    seriesInstanceUid,
                    sopInstanceUid,
                    cancellationToken);

                break;

            case ResourceType.Series:
                instancesToRetrieve = await instanceStore.GetInstanceIdentifiersInSeriesAsync(
                    partitionKey,
                    studyInstanceUid,
                    seriesInstanceUid,
                    cancellationToken);

                break;

            case ResourceType.Study:
                instancesToRetrieve = await instanceStore.GetInstanceIdentifiersInStudyAsync(
                    partitionKey,
                    studyInstanceUid,
                    cancellationToken);

                break;

            default:
                Debug.Fail($"Unknown retrieve transaction type: {resourceType}", nameof(resourceType));
                break;
            }

            if (!instancesToRetrieve.Any())
            {
                ThrowNotFoundException(resourceType);
            }

            return(instancesToRetrieve);
        }