public async void StoreItemsInCache_StoresAllItemsInTheCache()
        {
            // Arrange
            var mockProvider = new MockProvider();
            var dicomdirParser = mockProvider.GetDicomdirFileParserFake();
            dicomdirParser.ParseDicomdirAsync(Arg.Any<string>()).Returns(Task.FromResult(GetDicomdirInfosFake()));
            var cacheProvider = mockProvider.GetCacheProviderFake();
            var cacheIndexProvider = mockProvider.GetCacheIndexProviderFake();
            cacheIndexProvider.GetCacheIndex(Arg.Any<object>()).Returns(c => c.Arg<object>().GetType().Name);

            var dicomdirFileCacheStoreProvider = new DicomdirFileCacheStoreProvider(dicomdirParser, cacheProvider, cacheIndexProvider);

            // Act
            var result = await dicomdirFileCacheStoreProvider.StoreItemsInCache("");
            var patient = result.Patients.Single();
            var study = result.Studies.Single();
            var series = result.Series.First();

            // Assert
            Assert.That(patient.PatientName.ToString(), Is.EqualTo("John Doe"));
            Assert.That(patient.PatientID.StringRepresentationWithoutSlash, Is.EqualTo("9107256444"));
            Assert.That(study.StudyInstanceUID.StringRepresentation, Is.EqualTo("1.2"));
            Assert.That(series.StudyInstanceUID.StringRepresentation, Is.EqualTo("1.2"));
            Assert.That(series.SeriesInstanceUID.StringRepresentation, Is.EqualTo("1.3"));
            Assert.That(() => cacheProvider.Received(1).Store("PatientInfo", Arg.Any<object>(), true), Throws.Nothing);
            Assert.That(() => cacheProvider.Received(1).Store("StudyInfo", Arg.Any<object>(), true), Throws.Nothing);
            Assert.That(() => cacheProvider.Received(2).Store("SeriesInfo", Arg.Any<object>(), true), Throws.Nothing);
        }
        public async void HandleTypeAsync_AllSeries([Values(true, false)] bool useCache)
        {
            // Arrange
            var mockProvider = new MockProvider();
            var seriesInfoProvider = mockProvider.GetSeriesInfoProviderFake();
            var seriesQuery = Substitute.For<IDicomQuery<SeriesInfo>>();

            seriesInfoProvider.GetSeries().Returns(seriesQuery);
            var seriesTypeHandler = new SeriesTypeHandler(seriesInfoProvider, mockProvider.GetStudyInfoProviderFake());
            var inputArguments = new InputArguments(mockProvider.GetSettingsProviderFake(), mockProvider.GetBirthNumberParserFake())
            {
                Type = "series",
                UseCache = useCache
            };

            // Act
            await seriesTypeHandler.HandleTypeAsync(inputArguments, GetMemoryTextWriter());

            // Assert
            if (useCache)
            {
                Assert.That(() => seriesQuery.Received(1).LoadFromCache(), Throws.Nothing);
            }
            Assert.That(() => seriesInfoProvider.Received(1).GetSeries(), Throws.Nothing);
        }
        public void Constructor_ResponseCallbackIsCalled()
        {
            // Arrange
            var mockProvider = new MockProvider();
            var fellowOakMockProvider = new FellowOakMockProvider();
            var whereCollection = mockProvider.GetWhereCollection();
            var infoBuilder = mockProvider.GetDicomInfoBuilderFake();
            infoBuilder.BuildInfo<TestInfo>(Arg.Any<object>()).Returns(new TestInfo
            {
                PatientID = 666,
                PatientName = "patientName"
            });

            var response = new DicomCFindResponse(new DicomDataset())
            {
                Dataset = new DicomDataset()
            };
            TestInfo responseItem = null;
            var responseAction = new Action<TestInfo>(item =>
            {
                responseItem = item;
            });

            // Act
            var dicomFindRequest = new FellowOakDicomFindRequest<TestInfo>(mockProvider.GetDicomMappingFake(), fellowOakMockProvider.GetDicomTagAdapterFake(), infoBuilder, mockProvider.GetGeneralizedInfoProviderFake(), fellowOakMockProvider.GetDicomSopClassUidProviderFake(), responseAction, whereCollection.GetDicomWhereCollections().First());
            var innerRequest = (DicomCFindRequest)dicomFindRequest.InnerRequest;
            
            innerRequest.OnResponseReceived(null, response);

            // Assert
            Assert.That(responseItem.PatientID, Is.EqualTo(666));
            Assert.That(responseItem.PatientName, Is.EqualTo("patientName"));
        }
Ejemplo n.º 4
0
        public void Constructor_NullDownloadAction_ThrowsException()
        {
            // Arrange
            var mockProvider = new MockProvider();

            // Act + Assert
            Assert.That(() => new DicomStore(new MemoryStream(), null, mockProvider.GetLoggerFake()), Throws.InstanceOf<ArgumentNullException>());
        }
 public void Constructor_ArgumentsCombinations()
 {
     var mockProvider = new MockProvider();
     TestUtilities.TestConstructorArgumentsNullCombinations(typeof(DicomRequestFactory), null, new List<Func<object>>
     {
         mockProvider.GetSettingsProviderFake
     });
 }
 public void Constructor_ArgumentsCombinations()
 {
     var mockProvider = new MockProvider();
     TestUtilities.TestConstructorArgumentsNullCombinations(typeof(PatientTypeHandler), null, new List<Func<object>>
     {
         mockProvider.GetPatientInfoProviderFake
     });
 }
        public void CreateDicomServer_NullDownloadAction_ThrowsException()
        {
            // Arrange
            var mockProvider = new MockProvider();
            var serverFactory = new DicomServerFactory(mockProvider.GetSettingsProviderFake(), mockProvider.GetLoggerFake());

            // Act + Assert
            Assert.That(() => serverFactory.CreateDicomServer(null), Throws.TypeOf<ArgumentNullException>());
        }
Ejemplo n.º 8
0
        public void LoadDataFromServer_NullWhereCondition_ThrowsException()
        {
            // Arrange
            var mockProvider = new MockProvider();
            var dataLoader = mockProvider.GetDicomDataLoader();

            // Act + Assert
            Assert.That(() => dataLoader.LoadDataFromServer(null), Throws.TypeOf<ArgumentNullException>());
        }
Ejemplo n.º 9
0
        public void AddFindRequest_NullDicomRequest_ThrowsException()
        {
            // Arrange
            var mockProvider = new MockProvider();
            var dicomClient = new DicomClient<TestInfo>(mockProvider.GetSettingsProviderFake(), mockProvider.GetRequestAdapterFake());

            // Act + Assert
            Assert.That(() => dicomClient.AddFindRequest(null), Throws.InstanceOf<ArgumentNullException>());
        }
Ejemplo n.º 10
0
 public void OnReceiveAssociationRequest_NullAssociation_ThrowsException()
 {
     // Arrange
     var mockProvider = new MockProvider();
     var dicomStore = GetDicomStore(mockProvider.GetLoggerFake());
    
     // Act + Assert
     Assert.That(() => dicomStore.OnReceiveAssociationRequest(null), Throws.TypeOf<ArgumentNullException>());
 }
Ejemplo n.º 11
0
        public void Indexer_UndefinedDicomTag_ThrowsException()
        {
            // Arrange
            MockProvider mockProvider = new MockProvider();
            var whereCollection = mockProvider.GetWhereCollection();

            // Act + Assert
            Assert.That(() => whereCollection[DicomTags.Undefined], Throws.ArgumentException);
        }
 public void Constructor_ArgumentsCombinations()
 {
     var mockProvider = new MockProvider();
     TestUtilities.TestConstructorArgumentsNullCombinations(typeof(DicomClientFactory<>), new[] { typeof(TestInfo) }, new List<Func<object>>
     {
         mockProvider.GetSettingsProviderFake,
         mockProvider.GetRequestAdapterFake
     });
 }
        public void WhereLike_UndefinedDicomTag_ThrowsException()
        {
            // Arrange
            var mockProvider = new MockProvider();
            var dicomQuery = mockProvider.GetDicomQuery();

            // Act + Assert
            Assert.That(() => dicomQuery.WhereLike(DicomTags.Undefined, 0), Throws.ArgumentException);
        }
 public void Constructor_ArgumentsCombinations()
 {
     MockProvider mockProvider = new MockProvider();
     TestUtilities.TestConstructorArgumentsNullCombinations(typeof (StudyInfoProvider), null, new List<Func<object>>
     {
         mockProvider.GetDicomQueryProviderForStudiesFake,
         mockProvider.GetDicomDownloaderForStudiesFake
     });
 }
        public void WhereLike_NullValue_ThrowsException()
        {
            // Arrange
            var mockProvider = new MockProvider();
            var dicomQuery = mockProvider.GetDicomQuery();

            // Act + Assert
            Assert.That(() => dicomQuery.WhereLike(DicomTags.PatientName, null), Throws.TypeOf<ArgumentNullException>());
        }
        public void GetDicomQuery_ReturnsDicomQuery()
        {
            // Arrange
            var mockProvider = new MockProvider();
            var dicomQueryProvider = new DicomQueryProvider<TestInfo>(mockProvider.GetGeneralizedInfoProviderFake(), mockProvider.GetDicomDataLoaderFake());

            // Act + Assert
            Assert.That(() => dicomQueryProvider.GetDicomQuery(), Throws.Nothing);
        }
        public void CreateDicomMoveRequest_NullInfoIdentifier_ThrowsException()
        {
            // Arrange
            var mockProvider = new MockProvider();
            var dicomRequestFactory = new DicomRequestFactory(mockProvider.GetSettingsProviderFake());

            // Act + Assert
            Assert.That(() => dicomRequestFactory.CreateDicomMoveRequest(null), Throws.TypeOf<ArgumentNullException>());
        }
Ejemplo n.º 18
0
 public void Constructor_ArgumentsCombinations()
 {
     var mockProvider = new MockProvider();
     TestUtilities.TestConstructorArgumentsNullCombinations(typeof(InputArguments), null, new List<Func<object>>
     {
         mockProvider.GetSettingsProviderFake,
         mockProvider.GetBirthNumberParserFake
     });
 }
 public void Constructor_ArgumentsCombinations()
 {
     var mockProvider = new MockProvider();
     TestUtilities.TestConstructorArgumentsNullCombinations(typeof(DicomQueryProvider<>), new[] { typeof(TestInfo) }, new List<Func<object>>
     {
         mockProvider.GetGeneralizedInfoProviderFake,
         mockProvider.GetDicomDataLoaderFake
     });
 }
        public void SelectTypeHandler_UnknownType_ThrowsException()
        {
            // Arrange
            var mockProvider = new MockProvider();
            var typeHandlerSelector = new TypeHandlerSelector(mockProvider.GetPatientInfoProviderFake(), mockProvider.GetStudyInfoProviderFake(), mockProvider.GetSeriesInfoProviderFake());

            // Act + Assert
            Assert.That(() => typeHandlerSelector.SelectTypeHandler("unknownType"), Throws.ArgumentException);
        }
        public void SelectTypeHandler_NullType_ThrowsException()
        {
            // Arrange
            var mockProvider = new MockProvider();
            var typeHandlerSelector = new TypeHandlerSelector(mockProvider.GetPatientInfoProviderFake(), mockProvider.GetStudyInfoProviderFake(), mockProvider.GetSeriesInfoProviderFake());

            // Act + Assert
            Assert.That(() => typeHandlerSelector.SelectTypeHandler(null), Throws.InstanceOf<ArgumentNullException>());
        }
        public void CreateDicomFindRequest_NullResponseCallback_ThrowsException()
        {
            // Arrange
            var mockProvider = new MockProvider();
            var dicomRequestFactory = new DicomRequestFactory(mockProvider.GetSettingsProviderFake());

            // Act + Assert
            Assert.That(() => dicomRequestFactory.CreateDicomFindRequest<TestInfo>(mockProvider.GetDicomWhereCollectionFake(), null), Throws.TypeOf<ArgumentNullException>());
        }
Ejemplo n.º 23
0
 public void Constructor_ArgumentsCombinations()
 {
     var mockProvider = new MockProvider();
     TestUtilities.TestConstructorArgumentsNullCombinations(typeof(DicomDownloader<>), new[] { typeof(TestInfo) }, new List<Func<object>>
     {
         mockProvider.GetDicomServerFactoryFake,
         mockProvider.GetDicomClientFactoryFake,
         mockProvider.GetDicomRequestFactoryFake
     });
 }
 public void Constructor_ArgumentsCombinations()
 {
     var mockProvider = new MockProvider();
     TestUtilities.TestConstructorArgumentsNullCombinations(typeof (PatientInfoProvider), null, new List<Func<object>>
     {
         mockProvider.GetDicomQueryProviderForPatientsFake,
         mockProvider.GetStudyInfoProviderFake,
         mockProvider.GetBirthNumberParserFake
     });
 }
Ejemplo n.º 25
0
        public void BuildInfo_SourceNotConvertibleToDataset_ThrowsException()
        {
            // Arrange
            var mockProvider = new MockProvider();
            var fellowOakMockProvider = new FellowOakMockProvider();
            var dicomInfoBuilder = new DicomInfoBuilder(mockProvider.GetMappingEngine(), fellowOakMockProvider.GetDicomTagAdapterFake());

            // Act + Assert
            Assert.That(() => dicomInfoBuilder.BuildInfo<TestInfo>(new object()), Throws.ArgumentException);
        }
Ejemplo n.º 26
0
        public void BuildInfo_NullSource_ThrowsException()
        {
            // Arrange
            var mockProvider = new MockProvider();
            var fellowOakMockProvider = new FellowOakMockProvider();
            var dicomInfoBuilder = new DicomInfoBuilder(mockProvider.GetMappingEngine(), fellowOakMockProvider.GetDicomTagAdapterFake());

            // Act + Assert
            Assert.That(() => dicomInfoBuilder.BuildInfo<TestInfo>(null), Throws.InstanceOf<ArgumentNullException>());
        }
Ejemplo n.º 27
0
 public void Constructor_ArgumentsCombinations()
 {
     var mockProvider = new MockProvider();
     var fellowOakMockProvider = new FellowOakMockProvider();
     TestUtilities.TestConstructorArgumentsNullCombinations(typeof(DicomInfoBuilder), null, new List<Func<object>>
     {
         mockProvider.GetMappingEngine,
         fellowOakMockProvider.GetDicomTagAdapterFake
     });
 }
        public void DownloadImages_NullStudy_ThrowsException()
        {
            // Arrange
            MockProvider mockProvider = new MockProvider();
            StudyInfoProvider studyInfoProvider = new StudyInfoProvider(mockProvider.GetDicomQueryProviderForStudiesFake(), mockProvider.GetDicomDownloaderForStudiesFake());


            // Act + Assert
            Assert.That(() => studyInfoProvider.DownloadImagesAsync(null).Exception.InnerExceptions[0], Is.InstanceOf<ArgumentNullException>());
        }
 public void Constructor_ArgumentsCombinations()
 {
     var mockProvider = new MockProvider();
     TestUtilities.TestConstructorArgumentsNullCombinations(typeof(DicomdirFileCacheStoreProvider), null, new List<Func<object>>
     {
         mockProvider.GetDicomdirFileParserFake,
         mockProvider.GetCacheProviderFake,
         mockProvider.GetCacheIndexProviderFake
     });
 }
        public void SelectTypeHandler_ReturnsAccordingToTheType(string type, Type expectedType)
        {
            // Arrange
            var mockProvider = new MockProvider();
            var typeHandlerSelector = new TypeHandlerSelector(mockProvider.GetPatientInfoProviderFake(), mockProvider.GetStudyInfoProviderFake(), mockProvider.GetSeriesInfoProviderFake());

            // Act
            var handlerSelector = typeHandlerSelector.SelectTypeHandler(type);

            // Assert
            Assert.That(handlerSelector, Is.InstanceOf(expectedType));
        }