public async Task TestResourceIsUpdatedShouldReturnAskedVersionOnVRead()
        {
            var resourceTracker = new InMemoryResourceTracker();
            var repository      = new IotaFhirRepository(
                IotaResourceProvider.Repository,
                new FhirJsonTryteSerializer(),
                resourceTracker,
                new RandomSeedManager());

            var createdResource = await repository.CreateResourceAsync(FhirResourceProvider.Patient);

            var initialVersion = createdResource.VersionId;

            var updatedResource = await repository.UpdateResourceAsync(createdResource);

            var updatedVersionId = updatedResource.VersionId;

            await repository.UpdateResourceAsync(updatedResource);

            var readResource = await repository.ReadResourceVersionAsync(updatedVersionId);

            Assert.AreNotEqual(initialVersion, readResource.Meta.VersionId);
            Assert.AreEqual(updatedVersionId, readResource.Meta.VersionId);
            Assert.AreEqual(3, resourceTracker.Entries.First().ResourceRoots.Count);
        }
 public async Task TestResourceIsNotRegisteredInTrackerOnUpdateShouldThrowException()
 {
     var repository = new IotaFhirRepository(
         IotaResourceProvider.Repository,
         new FhirJsonTryteSerializer(),
         new InMemoryResourceTracker(),
         new RandomSeedManager());
     await repository.UpdateResourceAsync(FhirResourceProvider.Patient);
 }
        public async Task TestUpdatedResourceShouldReturnAllEntriesInHistory()
        {
            var resourceTracker = new InMemoryResourceTracker();
            var iotaRepository  = IotaResourceProvider.Repository;
            var repository      = new IotaFhirRepository(iotaRepository, new FhirJsonTryteSerializer(), resourceTracker, new RandomSeedManager(resourceTracker));

            var createdResource = await repository.CreateResourceAsync(FhirResourceProvider.Patient);

            var updatedResource = await repository.UpdateResourceAsync(createdResource);

            var resources = await repository.ReadResourceHistoryAsync(updatedResource.Id);

            Assert.AreEqual(2, resources.Count);
        }
        public async Task TestResourceIsReadOnlyShouldThrowException()
        {
            var resourceTracker = new InMemoryResourceTracker();
            await resourceTracker.AddEntryAsync(new ResourceEntry { ResourceRoots = new List <string> {
                                                                        "SOMEID"
                                                                    } });

            var repository = new IotaFhirRepository(
                IotaResourceProvider.Repository,
                new FhirJsonTryteSerializer(),
                resourceTracker,
                new RandomSeedManager());

            var resource = FhirResourceProvider.Patient;

            resource.Id = "SOMEID";

            await repository.UpdateResourceAsync(resource);
        }