예제 #1
0
        public async void GivenAFhirMediator_WhenSavingAnExportJobSucceeds_ThenResponseShouldBeSuccess()
        {
            var exportOutcome = new ExportJobOutcome(new ExportJobRecord(new Uri(RequestUrl)), WeakETag.FromVersionId("eTag"));

            _fhirDataStore.CreateExportJobAsync(Arg.Any <ExportJobRecord>(), Arg.Any <CancellationToken>()).Returns(exportOutcome);

            var outcome = await _mediator.ExportAsync(new Uri(RequestUrl));

            Assert.NotEmpty(outcome.JobId);
        }
        public async Task <CreateExportResponse> Handle(CreateExportRequest request, CancellationToken cancellationToken)
        {
            EnsureArg.IsNotNull(request, nameof(request));

            // TODO: Later we will add some logic here that will check whether a duplicate job already exists
            // and handle it accordingly. For now we just assume all export jobs are unique and create a new one.

            var jobRecord           = new ExportJobRecord(request.RequestUri);
            ExportJobOutcome result = await _fhirDataStore.CreateExportJobAsync(jobRecord, cancellationToken);

            // If job creation had failed we would have thrown an exception.
            return(new CreateExportResponse(jobRecord.Id));
        }