예제 #1
0
        public async Task GivenRetrieveStudyMetadataRequest_WhenInstanceIsDeletedInStudyAndPreviousETagIsUsed_ThenResponseMetadataIsReturnedWithNewETag()
        {
            string studyInstanceUid       = TestUidGenerator.Generate();
            string firstSeriesInstanceUid = TestUidGenerator.Generate();
            string firstSopInstanceUid    = TestUidGenerator.Generate();

            await PostDicomFileAsync(ResourceType.Instance, studyInstanceUid, firstSeriesInstanceUid, firstSopInstanceUid, dataSet : GenerateNewDataSet());

            DicomDataset secondStoredInstance = await PostDicomFileAsync(ResourceType.Study, studyInstanceUid, dataSet : GenerateNewDataSet());

            string eTag;

            using (DicomWebAsyncEnumerableResponse <DicomDataset> response = await _client.RetrieveStudyMetadataAsync(studyInstanceUid))
            {
                eTag = GetEtagFromResponse(response);
            }

            await _client.DeleteInstanceAsync(studyInstanceUid, firstSeriesInstanceUid, firstSopInstanceUid);

            using (DicomWebAsyncEnumerableResponse <DicomDataset> response = await _client.RetrieveStudyMetadataAsync(studyInstanceUid, eTag))
            {
                DicomDataset[] datasets = await response.ToArrayAsync();

                Assert.Single(datasets);
                ValidateResponseMetadataDataset(secondStoredInstance, datasets[0]);
            }
        }
예제 #2
0
        public async Task GivenDatasetInstancesWithDifferentPartitions_WhenDeleted_OneDeletedAndOtherRemains()
        {
            var newPartition1 = TestUidGenerator.Generate();
            var newPartition2 = TestUidGenerator.Generate();

            string studyInstanceUID  = TestUidGenerator.Generate();
            string seriesInstanceUID = TestUidGenerator.Generate();
            string sopInstanceUID    = TestUidGenerator.Generate();

            DicomFile dicomFile = Samples.CreateRandomDicomFile(studyInstanceUID, seriesInstanceUID, sopInstanceUID);

            using DicomWebResponse <DicomDataset> response1 = await _instancesManager.StoreAsync(new[] { dicomFile }, partitionName : newPartition1);

            using DicomWebResponse <DicomDataset> response2 = await _instancesManager.StoreAsync(new[] { dicomFile }, partitionName : newPartition2);

            using DicomWebResponse response3 = await _client.DeleteInstanceAsync(studyInstanceUID, seriesInstanceUID, sopInstanceUID, newPartition1);

            Assert.True(response3.IsSuccessStatusCode);

            await Assert.ThrowsAsync <DicomWebException>(() => _client.RetrieveInstanceAsync(studyInstanceUID, seriesInstanceUID, sopInstanceUID, partitionName: newPartition1));

            using DicomWebResponse <DicomFile> response5 = await _client.RetrieveInstanceAsync(studyInstanceUID, seriesInstanceUID, sopInstanceUID, partitionName : newPartition2);

            Assert.True(response5.IsSuccessStatusCode);
        }
예제 #3
0
        public async Task GivenDeleteRequestForInstance_WhenResourceExists_ThenAuditLogEntriesShouldBeCreated()
        {
            InstanceIdentifier dicomInstance = await CreateDicomFileAndGetInstanceIdentifierAsync();

            await ExecuteAndValidate(
                () => _client.DeleteInstanceAsync(dicomInstance.StudyInstanceUid, dicomInstance.SeriesInstanceUid, dicomInstance.SopInstanceUid),
                AuditEventSubType.Delete,
                $"studies/{dicomInstance.StudyInstanceUid}/series/{dicomInstance.SeriesInstanceUid}/instances/{dicomInstance.SopInstanceUid}",
                HttpStatusCode.NoContent);
        }
        [InlineData("1.2.840.10008.5.1.4.1.1.1", HttpStatusCode.BadRequest)]  // Valid UID, but not a transfer syntax
        public async Task GivenAnUnsupportedTransferSyntax_WhenRetrievingStudy_NotAcceptableIsReturned(string transferSyntax, HttpStatusCode expectedStatusCode)
        {
            IEnumerable <DicomFile> dicomFiles = Samples.GetDicomFilesForTranscoding();
            DicomFile dicomFile     = dicomFiles.FirstOrDefault(f => (Path.GetFileNameWithoutExtension(f.File.Name) == "ExplicitVRLittleEndian"));
            var       dicomInstance = dicomFile.Dataset.ToInstanceIdentifier();

            try
            {
                await _client.StoreAsync(new[] { dicomFile });

                DicomWebException exception = await Assert.ThrowsAsync <DicomWebException>(() => _client.RetrieveInstanceAsync(
                                                                                               dicomInstance.StudyInstanceUid, dicomInstance.SeriesInstanceUid, dicomInstance.SopInstanceUid, transferSyntax));

                Assert.Equal(expectedStatusCode, exception.StatusCode);
            }
            finally
            {
                await _client.DeleteInstanceAsync(dicomInstance.StudyInstanceUid, dicomInstance.SeriesInstanceUid, dicomInstance.SopInstanceUid);
            }
        }
예제 #5
0
 public async ValueTask DisposeAsync()
 {
     foreach (var id in _instanceIds)
     {
         try
         {
             await _dicomWebClient.DeleteInstanceAsync(id.StudyInstanceUid, id.SeriesInstanceUid, id.SopInstanceUid, id.PartitionName);
         }
         catch (DicomWebException)
         {
         }
     }
 }
예제 #6
0
        public async Task GivenAnExistingInstance_WhenDeletingInstance_TheServerShouldReturnNoContentAndAllLevelsShouldBeRemoved()
        {
            var studyInstanceUid  = TestUidGenerator.Generate();
            var seriesInstanceUid = TestUidGenerator.Generate();
            var sopInstanceUid    = TestUidGenerator.Generate();

            await CreateFile(studyInstanceUid, seriesInstanceUid, sopInstanceUid);

            using (DicomWebResponse response = await _client.DeleteInstanceAsync(studyInstanceUid, seriesInstanceUid, sopInstanceUid))
            {
                Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
            }

            await VerifyAllRemoval(studyInstanceUid, seriesInstanceUid, sopInstanceUid);
        }
예제 #7
0
        public async Task GivenADeletedAndReplacedInstance_WhenRetrievingChangeFeed_ThenTheExpectedInstanceAreReturned()
        {
            var studyInstanceUid  = TestUidGenerator.Generate();
            var seriesInstanceUid = TestUidGenerator.Generate();
            var sopInstanceUid    = TestUidGenerator.Generate();

            await CreateFile(studyInstanceUid, seriesInstanceUid, sopInstanceUid);

            long initialSequence;

            using (DicomWebResponse <ChangeFeedEntry> response = await _client.GetChangeFeedLatest())
            {
                initialSequence = (await ValidateFeedAsync(response, ChangeFeedAction.Create, ChangeFeedState.Current)).Sequence;
            }

            await _client.DeleteInstanceAsync(studyInstanceUid, seriesInstanceUid, sopInstanceUid);

            using (DicomWebResponse <ChangeFeedEntry> response = await _client.GetChangeFeedLatest())
            {
                await ValidateFeedAsync(response, ChangeFeedAction.Delete, ChangeFeedState.Deleted);
            }

            await CreateFile(studyInstanceUid, seriesInstanceUid, sopInstanceUid);

            using (DicomWebResponse <ChangeFeedEntry> response = await _client.GetChangeFeedLatest())
            {
                await ValidateFeedAsync(response, ChangeFeedAction.Create, ChangeFeedState.Current);
            }

            using (DicomWebAsyncEnumerableResponse <ChangeFeedEntry> response = await _client.GetChangeFeed($"?offset={initialSequence - 1}"))
            {
                ChangeFeedEntry[] changeFeedResults = await response.ToArrayAsync();

                Assert.Equal(3, changeFeedResults.Length);

                Assert.Equal(ChangeFeedState.Replaced, changeFeedResults[0].State);
                Assert.Equal(ChangeFeedState.Replaced, changeFeedResults[1].State);
                Assert.Equal(ChangeFeedState.Current, changeFeedResults[2].State);
            }

            async Task <ChangeFeedEntry> ValidateFeedAsync(DicomWebResponse <ChangeFeedEntry> response, ChangeFeedAction action, ChangeFeedState state)
            {
                ChangeFeedEntry changeFeedEntry = await response.GetValueAsync();

                Assert.Equal(studyInstanceUid, changeFeedEntry.StudyInstanceUid);
                Assert.Equal(seriesInstanceUid, changeFeedEntry.SeriesInstanceUid);
                Assert.Equal(sopInstanceUid, changeFeedEntry.SopInstanceUid);
                Assert.Equal(action, changeFeedEntry.Action);
                Assert.Equal(state, changeFeedEntry.State);

                if (state == ChangeFeedState.Deleted)
                {
                    Assert.Null(changeFeedEntry.Metadata);
                }
                else
                {
                    Assert.NotNull(changeFeedEntry.Metadata);
                }

                return(changeFeedEntry);
            }
        }