Beispiel #1
0
        public async Task GivenInvalidAuthorization_WhenHandlingRequest_ThenThrowUnauthorizedDicomActionException()
        {
            using var source = new CancellationTokenSource();
            IAuthorizationService <DataActions> auth = Substitute.For <IAuthorizationService <DataActions> >();
            IDicomOperationsClient client            = Substitute.For <IDicomOperationsClient>();
            var handler = new OperationStatusHandler(auth, client);

            auth.CheckAccess(DataActions.Read, source.Token).Returns(DataActions.None);

            await Assert.ThrowsAsync <UnauthorizedDicomActionException>(() => handler.Handle(new OperationStatusRequest(Guid.NewGuid()), source.Token));

            await auth.Received(1).CheckAccess(DataActions.Read, source.Token);

            await client.DidNotReceiveWithAnyArgs().GetStatusAsync(default, default);
Beispiel #2
0
        public async Task GivenInvalidInput_WhenAddingExtendedQueryTag_ThenStopAfterValidation()
        {
            DicomTag tag = DicomTag.DeviceSerialNumber;
            AddExtendedQueryTagEntry entry = tag.BuildAddExtendedQueryTagEntry();
            var exception = new ExtendedQueryTagEntryValidationException(string.Empty);

            var input = new AddExtendedQueryTagEntry[] { entry };

            _extendedQueryTagEntryValidator.WhenForAnyArgs(v => v.ValidateExtendedQueryTags(input)).Throw(exception);

            await Assert.ThrowsAsync <ExtendedQueryTagEntryValidationException>(
                () => _extendedQueryTagService.AddExtendedQueryTagsAsync(input, _tokenSource.Token));

            _extendedQueryTagEntryValidator.Received(1).ValidateExtendedQueryTags(input);
            await _client.DidNotReceiveWithAnyArgs().StartReindexingInstancesAsync(default, default);