Пример #1
0
        public async Task GivenACreateResourceRequest_WhenCreatingAResourceOtherThanSearchParameter_ThenNoCallToAddParameterMade()
        {
            var resource = Samples.GetDefaultObservation().UpdateId("id1");

            var request = new CreateResourceRequest(resource);
            var wrapper = CreateResourceWrapper(resource, false);

            var response = new UpsertResourceResponse(new SaveOutcome(new RawResourceElement(wrapper), SaveOutcomeType.Created));

            var behavior = new CreateOrUpdateSearchParameterBehavior <CreateResourceRequest, UpsertResourceResponse>(_searchParameterOperations, _fhirDataStore);
            await behavior.Handle(request, CancellationToken.None, async() => await Task.Run(() => response));

            // Ensure for non-SearchParameter, that we do not call Add SearchParameter
            await _searchParameterOperations.DidNotReceive().AddSearchParameterAsync(Arg.Any <ITypedElement>());
        }
Пример #2
0
        public async Task GivenACreateResourceRequest_WhenCreatingASearchParameterResource_ThenAddNewSearchParameterShouldBeCalled()
        {
            var searchParameter = new SearchParameter()
            {
                Id = "Id"
            };
            var resource = searchParameter.ToTypedElement().ToResourceElement();

            var request = new CreateResourceRequest(resource);
            var wrapper = CreateResourceWrapper(resource, false);

            var response = new UpsertResourceResponse(new SaveOutcome(new RawResourceElement(wrapper), SaveOutcomeType.Created));

            var behavior = new CreateOrUpdateSearchParameterBehavior <CreateResourceRequest, UpsertResourceResponse>(_searchParameterOperations, _fhirDataStore);
            await behavior.Handle(request, CancellationToken.None, async() => await Task.Run(() => response));

            await _searchParameterOperations.Received().AddSearchParameterAsync(Arg.Any <ITypedElement>());
        }