public async Task GivenADatabaseSupportsResourceChangeCapture_WhenResourceChangeCaptureIsDisabled_ThenResourceChangesShouldNotBeCreated()
        {
            FhirStorageTestsFixture fhirStorageTestsFixture = null;

            try
            {
                string databaseName = $"FHIRRESOURCECHANGEDISABLEDTEST_{DateTimeOffset.UtcNow.ToUnixTimeSeconds()}_{BigInteger.Abs(new BigInteger(Guid.NewGuid().ToByteArray()))}";

                // this will either create the database or upgrade the schema.
                var coreFeatureConfigOptions = Options.Create(new CoreFeatureConfiguration()
                {
                    SupportsResourceChangeCapture = false
                });
                var sqlFixture = new SqlServerFhirStorageTestsFixture(SchemaVersionConstants.Max, databaseName, coreFeatureConfigOptions);

                fhirStorageTestsFixture = new FhirStorageTestsFixture(sqlFixture);
                await fhirStorageTestsFixture.InitializeAsync();

                Mediator mediator = fhirStorageTestsFixture.Mediator;

                // add a new resource
                var saveResult = await mediator.UpsertResourceAsync(Samples.GetJsonSample("Weight"));

                // update the resource
                var newResourceValues = Samples.GetJsonSample("WeightInGrams").ToPoco();
                newResourceValues.Id = saveResult.RawResourceElement.Id;

                // save updated resource
                var updateResult = await mediator.UpsertResourceAsync(newResourceValues.ToResourceElement(), WeakETag.FromVersionId(saveResult.RawResourceElement.VersionId));

                // delete the resource
                var deletedResourceKey = await mediator.DeleteResourceAsync(new ResourceKey("Observation", saveResult.RawResourceElement.Id), DeleteOperation.SoftDelete);

                // get resource changes
                var resourceChangeDataStore = new SqlServerFhirResourceChangeDataStore(sqlFixture.SqlConnectionWrapperFactory, NullLogger <SqlServerFhirResourceChangeDataStore> .Instance, sqlFixture.SchemaInformation);
                var resourceChanges         = await resourceChangeDataStore.GetRecordsAsync(1, 200, CancellationToken.None);

                Assert.NotNull(resourceChanges);
                Assert.Empty(resourceChanges);
            }
            finally
            {
                await fhirStorageTestsFixture?.DisposeAsync();
            }
        }
Пример #2
0
 public async Task InitializeAsync()
 {
     await _storageFixture.InitializeAsync();
 }