public async Task TestResourceIsNotRegisteredInTrackerOnReadShouldThrowException()
 {
     var repository = new IotaFhirRepository(
         IotaResourceProvider.Repository,
         new FhirJsonTryteSerializer(),
         new InMemoryResourceTracker(),
         new RandomSeedManager());
     await repository.ReadResourceAsync("SOMEID");
 }
        public async Task TestResourceCanBeReadFromTangle()
        {
            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 readResource = await repository.ReadResourceAsync(createdResource.Id);

            Assert.IsTrue(createdResource.IsExactly(readResource));
        }
        public async Task TestResourceIsUpdatedShouldReturnNewVersionOnRead()
        {
            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 initialVersion = createdResource.Meta.VersionId;

            var updatedResource = await repository.UpdateResourceAsync(createdResource);

            var readResource = await repository.ReadResourceAsync(updatedResource.Id);

            Assert.AreNotEqual(initialVersion, readResource.Meta.VersionId);
            Assert.AreEqual(2, resourceTracker.Entries.First().ResourceRoots.Count);
        }
        public async Task TestNoMessagesAreOnMamStreamShouldThrowException()
        {
            var iotaRepository      = IotaResourceProvider.Repository;
            var channelFactory      = new MamChannelFactory(CurlMamFactory.Default, CurlMerkleTreeFactory.Default, iotaRepository);
            var subscriptionFactory = new MamChannelSubscriptionFactory(iotaRepository, CurlMamParser.Default, CurlMask.Default);

            var resourceTracker = new InMemoryResourceTracker();
            await resourceTracker.AddEntryAsync(
                new ResourceEntry
            {
                Channel       = channelFactory.Create(Mode.Restricted, Seed.Random(), SecurityLevel.Medium, Seed.Random().Value, true),
                Subscription  = subscriptionFactory.Create(new Hash(Seed.Random().Value), Mode.Restricted, Seed.Random().Value, true),
                ResourceRoots = new List <string> {
                    "SOMEID"
                }
            });

            var repository = new IotaFhirRepository(
                iotaRepository,
                new FhirJsonTryteSerializer(),
                resourceTracker,
                new RandomSeedManager());
            await repository.ReadResourceAsync("SOMEID");
        }