public void GetPatientByBirthNumberAsync_InvalidBirthNumber_ThrowsException()
        {
            // Arrange
            var mockProvider = new MockProvider();
            var patientInfoProvider = new PatientInfoProvider(mockProvider.GetDicomQueryProviderForPatientsFake(), mockProvider.GetStudyInfoProviderFake(), new BirthNumberParser());

            // Act
            var exception = patientInfoProvider.GetPatientByBirthNumberAsync("910725/6443").Exception;
                
            // Act + Assert
            Assert.That(exception.InnerExceptions.First(), Is.TypeOf<ArgumentException>());
        }
        public async void DownloadImages_ProperMethodsAreCalled()
        {
            // Arrange
            var mockProvider = new MockProvider();
            var studyInfoProvider = Substitute.For<IStudyInfoProvider>();
            var dataLoader = Substitute.For<IDicomDataLoader<StudyInfo>>();
            var whereCollection = Substitute.For<WhereCollection<StudyInfo>>(mockProvider.GetDicomMappingFake());
            var query = Substitute.For<DicomQuery<StudyInfo>>(mockProvider.GetGeneralizedInfoProviderFake(), dataLoader, whereCollection);
            
            dataLoader.LoadDataFromServerAsync(Arg.Any<IWhereCollection<StudyInfo>>()).Returns(c =>
                Task<IImmutableList<StudyInfo>>.Factory.StartNew(() => 
                    new List<StudyInfo>
                    {
                        new StudyInfo(),
                        new StudyInfo()
                    }.ToImmutableList()));
            
            studyInfoProvider.GetStudiesForPatient(Arg.Any<PatientInfo>()).Returns(query);
            var patientInfoProvider = new PatientInfoProvider(mockProvider.GetDicomQueryProviderForPatientsFake(), studyInfoProvider, mockProvider.GetBirthNumberParserFake());
            var patient = new PatientInfo();
                
            // Act
            await patientInfoProvider.DownloadImagesAsync(patient);

            // Assert
            Assert.That(() => studyInfoProvider.Received(1).GetStudiesForPatient(patient), Throws.Nothing);
            Assert.That(() => studyInfoProvider.Received(2).DownloadImagesAsync(Arg.Any<StudyInfo>(), Arg.Any<Func<InfoIdentifier, InfoIdentifier, Stream>>()), Throws.Nothing);
        }
        public void DownloadImages_NullPatient_ThrowsException()
        {
            // Arrange
            var mockProvider = new MockProvider();
            var patientInfoProvider = new PatientInfoProvider(mockProvider.GetDicomQueryProviderForPatientsFake(), mockProvider.GetStudyInfoProviderFake(), mockProvider.GetBirthNumberParserFake());

            // Act + Assert
            Assert.That(() => patientInfoProvider.DownloadImagesAsync(null).Exception.InnerExceptions[0], Is.InstanceOf<ArgumentNullException>());
        }