Beispiel #1
0
        public async Task GivenRequestForExtendedQueryTagError_WhenTagExists_ThenReturnExtendedQueryTagErrorsList()
        {
            string tagPath = DicomTag.DeviceID.GetPath();

            var expected = new List <ExtendedQueryTagError> {
                new ExtendedQueryTagError(
                    DateTime.UtcNow,
                    Guid.NewGuid().ToString(),
                    Guid.NewGuid().ToString(),
                    Guid.NewGuid().ToString(),
                    "fake error message")
            };

            DicomTag[] parsedTags = new DicomTag[] { DicomTag.DeviceID };

            _dicomTagParser.TryParse(tagPath, out Arg.Any <DicomTag[]>()).Returns(x =>
            {
                x[1] = parsedTags;
                return(true);
            });

            _extendedQueryTagErrorStore.GetExtendedQueryTagErrorsAsync(tagPath, 5, 100).Returns(expected);
            GetExtendedQueryTagErrorsResponse response = await _extendedQueryTagErrorsService.GetExtendedQueryTagErrorsAsync(tagPath, 5, 100);

            await _extendedQueryTagErrorStore.Received(1).GetExtendedQueryTagErrorsAsync(tagPath, 5, 100);

            _dicomTagParser.Received(1).TryParse(
                Arg.Is(tagPath),
                out Arg.Any <DicomTag[]>());
            Assert.Equal(expected, response.ExtendedQueryTagErrors);
        }
Beispiel #2
0
        public async Task <IActionResult> GetTagErrorsAsync(
            [FromRoute] string tagPath,
            [FromQuery] PaginationOptions options)
        {
            _logger.LogInformation("DICOM Web Get Extended Query Tag Errors request received for extended query tag: {TagPath}", tagPath);

            EnsureArg.IsNotNull(options, nameof(options));
            EnsureFeatureIsEnabled();
            GetExtendedQueryTagErrorsResponse response = await _mediator.GetExtendedQueryTagErrorsAsync(
                tagPath,
                options.Limit,
                options.Offset,
                HttpContext.RequestAborted);

            return(StatusCode((int)HttpStatusCode.OK, response.ExtendedQueryTagErrors));
        }
Beispiel #3
0
        public async Task GivenTagPath_WhenCallingApi_ThenShouldReturnOk()
        {
            IMediator    mediator = Substitute.For <IMediator>();
            const string path     = "11330001";

            var controller = new ExtendedQueryTagController(
                mediator,
                Options.Create(new FeatureConfiguration {
                EnableExtendedQueryTags = true
            }),
                NullLogger <ExtendedQueryTagController> .Instance);

            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            var expected = new GetExtendedQueryTagErrorsResponse(
                new List <ExtendedQueryTagError>
            {
                new ExtendedQueryTagError(DateTime.UtcNow, Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "Error 1"),
                new ExtendedQueryTagError(DateTime.UtcNow, Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "Error 2"),
                new ExtendedQueryTagError(DateTime.UtcNow, Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), "Error 3"),
            });

            mediator
            .Send(
                Arg.Is <GetExtendedQueryTagErrorsRequest>(x => x.Path == path),
                Arg.Is(controller.HttpContext.RequestAborted))
            .Returns(expected);

            IActionResult response = await controller.GetTagErrorsAsync(path, new PaginationOptions());

            Assert.IsType <ObjectResult>(response);

            var actual = response as ObjectResult;

            Assert.Equal((int)HttpStatusCode.OK, actual.StatusCode);
            Assert.Same(expected.ExtendedQueryTagErrors, actual.Value);

            await mediator.Received(1).Send(
                Arg.Is <GetExtendedQueryTagErrorsRequest>(x => x.Path == path),
                Arg.Is(controller.HttpContext.RequestAborted));
        }
Beispiel #4
0
        public async Task GivenRequestForExtendedQueryTagError_WhenTagDoesNotExist_ThenReturnEmptyList()
        {
            string tagPath = DicomTag.DeviceID.GetPath();

            DicomTag[] parsedTags = new DicomTag[] { DicomTag.DeviceID };

            _dicomTagParser.TryParse(tagPath, out Arg.Any <DicomTag[]>()).Returns(x =>
            {
                x[1] = parsedTags;
                return(true);
            });

            _extendedQueryTagErrorStore.GetExtendedQueryTagErrorsAsync(tagPath, 100, 200).Returns(Array.Empty <ExtendedQueryTagError>());
            GetExtendedQueryTagErrorsResponse response = await _extendedQueryTagErrorsService.GetExtendedQueryTagErrorsAsync(tagPath, 100, 200);

            _dicomTagParser.Received(1).TryParse(
                Arg.Is(tagPath),
                out Arg.Any <DicomTag[]>());
            await _extendedQueryTagErrorStore.Received(1).GetExtendedQueryTagErrorsAsync(tagPath, 100, 200);

            Assert.Empty(response.ExtendedQueryTagErrors);
        }