public async Task GivenUpdatedResources_WhenBulkUpdatingSearchParameterIndicesAsync_ThenResourceMetadataIsUnchanged() { ResourceElement patientResource1 = CreatePatientResourceElement("Patient1", Guid.NewGuid().ToString()); SaveOutcome upsertResult1 = await Mediator.UpsertResourceAsync(patientResource1); ResourceElement patientResource2 = CreatePatientResourceElement("Patient2", Guid.NewGuid().ToString()); SaveOutcome upsertResult2 = await Mediator.UpsertResourceAsync(patientResource2); SearchParameter searchParam = null; const string searchParamName = "newSearchParam"; try { searchParam = await CreatePatientSearchParam(searchParamName, SearchParamType.String, "Patient.name"); ISearchValue searchValue = new StringSearchValue(searchParamName); (ResourceWrapper original1, ResourceWrapper updated1) = await CreateUpdatedWrapperFromExistingPatient(upsertResult1, searchParam, searchValue); (ResourceWrapper original2, ResourceWrapper updated2) = await CreateUpdatedWrapperFromExistingPatient(upsertResult2, searchParam, searchValue); var resources = new List <ResourceWrapper> { updated1, updated2 }; await _dataStore.BulkUpdateSearchParameterIndicesAsync(resources, CancellationToken.None); // Get the reindexed resources from the database var resourceKey1 = new ResourceKey(upsertResult1.RawResourceElement.InstanceType, upsertResult1.RawResourceElement.Id, upsertResult1.RawResourceElement.VersionId); ResourceWrapper reindexed1 = await _dataStore.GetAsync(resourceKey1, CancellationToken.None); var resourceKey2 = new ResourceKey(upsertResult2.RawResourceElement.InstanceType, upsertResult2.RawResourceElement.Id, upsertResult2.RawResourceElement.VersionId); ResourceWrapper reindexed2 = await _dataStore.GetAsync(resourceKey2, CancellationToken.None); VerifyReindexedResource(original1, reindexed1); VerifyReindexedResource(original2, reindexed2); } finally { if (searchParam != null) { _searchParameterDefinitionManager.DeleteSearchParameter(searchParam.ToTypedElement()); await _fixture.TestHelper.DeleteSearchParameterStatusAsync(searchParam.Url, CancellationToken.None); } } }