예제 #1
0
        public async Task GivenAcquireExportJobThrowsException_WhenExecuted_ThenWeHaveADelayBeforeWeRetry()
        {
            _fhirOperationDataStore.AcquireExportJobsAsync(
                DefaultMaximumNumberOfConcurrentJobAllowed,
                DefaultJobHeartbeatTimeoutThreshold,
                _cancellationToken)
            .ThrowsForAnyArgs <Exception>();

            _cancellationTokenSource.CancelAfter(DefaultJobPollingFrequency * 1.25);

            await _exportJobWorker.ExecuteAsync(_cancellationToken);

            // Assert that we received only one call to AcquireExportJobsAsync
            await _fhirOperationDataStore.ReceivedWithAnyArgs(1).AcquireExportJobsAsync(Arg.Any <ushort>(), Arg.Any <TimeSpan>(), Arg.Any <CancellationToken>());
        }
예제 #2
0
        public async Task GivenTaskCouldNotBeAcquired_WhenExecuted_ThenNoFurtherActionShouldBeTaken()
        {
            _fhirOperationDataStore.UpdateExportJobAsync(_exportJobRecord, _weakETag, _cancellationToken).Returns(_ => Task.Run(new Func <Task <ExportJobOutcome> >(() => throw new JobConflictException())));

            await _exportJobTask.ExecuteAsync(_exportJobRecord, _weakETag, _cancellationToken);

            await _fhirOperationDataStore.ReceivedWithAnyArgs(1).UpdateExportJobAsync(null, null, _cancellationToken);
        }