コード例 #1
0
 public async Task TestResourceIsNotRegisteredInTrackerOnReadShouldThrowException()
 {
     var repository = new IotaFhirRepository(
         IotaResourceProvider.Repository,
         new FhirJsonTryteSerializer(),
         new InMemoryResourceTracker(),
         new RandomSeedManager());
     await repository.ReadResourceAsync("SOMEID");
 }
コード例 #2
0
        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));
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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");
        }