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"));
        }
        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);
        }
        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>());
        }
예제 #4
0
        public void AddFindRequest_RequestAdapterIsCalled()
        {
            // Arrange
            var mockProvider = new MockProvider();
            var fellowOakMockProvider = new FellowOakMockProvider();
            var requestAdapter = mockProvider.GetRequestAdapterFake();
            var dicomClient = new DicomClient<TestInfo>(mockProvider.GetSettingsProviderFake(), requestAdapter);
            var dicomFindRequest = new FellowOakDicomFindRequest<TestInfo>(mockProvider.GetDicomMappingFake(),fellowOakMockProvider.GetDicomTagAdapterFake(), mockProvider.GetDicomInfoBuilderFake(), mockProvider.GetGeneralizedInfoProviderFake(), fellowOakMockProvider.GetDicomSopClassUidProviderFake(), c=> {},mockProvider.GetDicomWhereCollectionFake());

            // Act
            dicomClient.AddFindRequest(dicomFindRequest);

            // Assert
            Assert.That(() => requestAdapter.Received(1).CreateFindDicomRequest(dicomFindRequest), Throws.Nothing);
        }
        public void Constructor_CreatesInnerRequestWithWhereConditions()
        {
            // Arrange
            var mockProvider = new MockProvider();
            var fellowOakMockProvider = new FellowOakMockProvider();
            var whereCollection = mockProvider.GetWhereCollection();
            whereCollection.WhereEquals(DicomTags.PatientID, "PatientIDValue");
            whereCollection.WhereLike(DicomTags.PatientName, "PatientNameValue");

            // Act
            var dicomFindRequest = new FellowOakDicomFindRequest<TestInfo>(mockProvider.GetDicomMappingFake(), fellowOakMockProvider.GetDicomTagAdapterFake(), mockProvider.GetDicomInfoBuilderFake(), mockProvider.GetGeneralizedInfoProviderFake(), fellowOakMockProvider.GetDicomSopClassUidProviderFake(), c => {}, whereCollection.GetDicomWhereCollections().First());
            var innerRequestDataset = dicomFindRequest.InnerRequest.Dataset;

            // Assert
            Assert.That(innerRequestDataset.Get<string>(DicomTag.PatientID), Is.EqualTo("PatientIDValue"));
            Assert.That(innerRequestDataset.Get<string>(DicomTag.PatientName), Is.EqualTo("*PatientNameValue*"));
        }
        public void BuildInfo_DataSetPassed_BuildsCorrectTestInfo()
        {
            // Arrange
            var mockProvider = new MockProvider();
            var fellowOakMockProvider = new FellowOakMockProvider();
            var dicomInfoBuilder = new DicomInfoBuilder(mockProvider.GetMappingEngine(), fellowOakMockProvider.GetDicomTagAdapterFake());
            var dataset = new DicomDataset
            {
                {
                    DicomTag.PatientID, "666"
                },
                {
                    DicomTag.PatientName, "testName"
                }
            };

            // Act
            var result = dicomInfoBuilder.BuildInfo<TestInfo>(dataset);

            // Assert
            Assert.That(result.PatientID, Is.EqualTo(666));
            Assert.That(result.PatientName, Is.EqualTo("testName"));
        }
        private IDicomRequestAdapter<TestInfo> GetDicomRequestAdapter()
        {
            var mockProvider = new MockProvider();
            var fellowOakMockProvider = new FellowOakMockProvider();

            return new DicomRequestAdapter<TestInfo>(fellowOakMockProvider.GetDicomTagAdapterFake(), mockProvider.GetDicomInfoBuilderFake(), mockProvider.GetGeneralizedInfoProviderFake(),
                fellowOakMockProvider.GetDicomSopClassUidProviderFake());
        }