Esempio n. 1
0
        public async Task GivenASetOfDicomInstances_WhenRetrievingChangeFeed_ThenTheExpectedInstanceAreReturned()
        {
            var  studyInstanceUid  = TestUidGenerator.Generate();
            var  seriesInstanceUid = TestUidGenerator.Generate();
            var  sopInstanceUids   = Enumerable.Range(1, 10).Select(x => TestUidGenerator.Generate()).ToArray();
            long initialSequence   = -1;

            for (int i = 0; i < 10; i++)
            {
                await CreateFile(studyInstanceUid, seriesInstanceUid, sopInstanceUids[i]);

                if (initialSequence == -1)
                {
                    using DicomWebResponse <ChangeFeedEntry> latestResponse = await _client.GetChangeFeedLatest();

                    ChangeFeedEntry result = await latestResponse.GetValueAsync();

                    initialSequence = result.Sequence;
                    Assert.Equal(studyInstanceUid, result.StudyInstanceUid);
                    Assert.Equal(seriesInstanceUid, result.SeriesInstanceUid);
                    Assert.Equal(sopInstanceUids[i], result.SopInstanceUid);
                    Assert.Equal(ChangeFeedAction.Create, result.Action);
                    Assert.Equal(ChangeFeedState.Current, result.State);
                }
            }

            using (DicomWebAsyncEnumerableResponse <ChangeFeedEntry> response = await _client.GetChangeFeed())
            {
                Assert.Equal(10, await response.CountAsync());
            }

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

                Assert.Equal(10, changeFeedResults.Length);

                for (int i = 0; i < 10; i++)
                {
                    Assert.Equal(studyInstanceUid, changeFeedResults[i].StudyInstanceUid);
                    Assert.Equal(seriesInstanceUid, changeFeedResults[i].SeriesInstanceUid);
                    Assert.Equal(sopInstanceUids[i], changeFeedResults[i].SopInstanceUid);
                    Assert.NotNull(changeFeedResults[i].Metadata);
                }
            }
        }
Esempio n. 2
0
        public async Task GivenAnInstance_WhenRetrievingChangeFeedWithPartition_ThenPartitionNameIsReturned()
        {
            var    newPartition      = 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 : newPartition);

            Assert.True(response1.IsSuccessStatusCode);

            long initialSequence;

            using (DicomWebResponse <ChangeFeedEntry> response = await _client.GetChangeFeedLatest("?includemetadata=false"))
            {
                ChangeFeedEntry changeFeedEntry = await response.GetValueAsync();

                initialSequence = changeFeedEntry.Sequence;

                Assert.Equal(newPartition, changeFeedEntry.PartitionName);
                Assert.Equal(studyInstanceUID, changeFeedEntry.StudyInstanceUid);
                Assert.Equal(seriesInstanceUID, changeFeedEntry.SeriesInstanceUid);
                Assert.Equal(sopInstanceUID, changeFeedEntry.SopInstanceUid);
            }

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

                Assert.Single(changeFeedResults);
                Assert.Null(changeFeedResults[0].Metadata);
                Assert.Equal(newPartition, changeFeedResults[0].PartitionName);
                Assert.Equal(ChangeFeedState.Current, changeFeedResults[0].State);
            }
        }