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"));
        }
Пример #2
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*"));
        }