public async Task TestResourceDoesNotExistShouldReturnErrorCode() { var interactor = new ReadResourceHistoryInteractor(new InMemoryFhirRepository()); var response = await interactor.ExecuteAsync(new ReadResourceHistoryRequest { ResourceId = "kasfasagdssg", ResourceType = "Patient" }); Assert.AreEqual(ResponseCode.ResourceNotFound, response.Code); }
public async Task TestRepositoryReturnsNoResourcesShouldReturnErrorCode() { var repository = new Mock <IFhirRepository>(); repository.Setup(r => r.ReadResourceHistoryAsync(It.IsAny <string>())).ReturnsAsync(new List <Resource>()); var interactor = new ReadResourceHistoryInteractor(repository.Object); var response = await interactor.ExecuteAsync(new ReadResourceHistoryRequest { ResourceId = "kasfasagdssg", ResourceType = "Patient" }); Assert.AreEqual(ResponseCode.ResourceNotFound, response.Code); }
private void InjectDependencies(IServiceCollection services) { var iotaRepository = new CachedIotaRestRepository( new FallbackIotaClient(new List <string> { "https://nodes.devnet.thetangle.org:443" }, 5000), new PoWService(new CpuPearlDiver())); var channelFactory = new MamChannelFactory(CurlMamFactory.Default, CurlMerkleTreeFactory.Default, iotaRepository); var subscriptionFactory = new MamChannelSubscriptionFactory(iotaRepository, CurlMamParser.Default, CurlMask.Default); var encryption = new RijndaelEncryption("somenicekey", "somenicesalt"); var resourceTracker = new SqlLiteResourceTracker(channelFactory, subscriptionFactory, encryption); var seedManager = new SqlLiteDeterministicSeedManager( resourceTracker, new IssSigningHelper(new Curl(), new Curl(), new Curl()), new AddressGenerator(), iotaRepository, encryption); var fhirRepository = new IotaFhirRepository(iotaRepository, new FhirJsonTryteSerializer(), resourceTracker, seedManager); var fhirParser = new FhirJsonParser(); var searchRepository = new SqlLiteSearchRepository(fhirParser); var createInteractor = new CreateResourceInteractor(fhirRepository, fhirParser, searchRepository); var readInteractor = new ReadResourceInteractor(fhirRepository, searchRepository); var readVersionInteractor = new ReadResourceVersionInteractor(fhirRepository); var readHistoryInteractor = new ReadResourceHistoryInteractor(fhirRepository); var capabilitiesInteractor = new GetCapabilitiesInteractor(fhirRepository, new AppConfigSystemInformation(this.Configuration)); var validationInteractor = new ValidateResourceInteractor(fhirRepository, fhirParser); var searchInteractor = new SearchResourcesInteractor(fhirRepository, searchRepository); var deleteInteractor = new DeleteResourceInteractor(fhirRepository, searchRepository); var resourceImporter = new ResourceImporter(searchRepository, fhirRepository, seedManager); services.AddScoped(provider => createInteractor); services.AddScoped(provider => readInteractor); services.AddScoped(provider => capabilitiesInteractor); services.AddScoped(provider => validationInteractor); services.AddScoped(provider => searchInteractor); services.AddScoped(provider => resourceImporter); services.AddScoped(provider => readVersionInteractor); services.AddScoped(provider => readHistoryInteractor); services.AddScoped(provider => deleteInteractor); services.AddScoped <ISeedManager>(provider => seedManager); services.AddSingleton <IMemoryCache>(new Microsoft.Extensions.Caching.Memory.MemoryCache(new MemoryCacheOptions())); }
public async Task TestResourceTypeMismatchShouldReturnErrorCode() { var resource = FhirResourceProvider.Patient; resource.Id = "SOMEFHIRCONFORMID"; var repository = new InMemoryFhirRepository(); repository.Resources.Add(resource); var interactor = new ReadResourceHistoryInteractor(repository); var response = await interactor.ExecuteAsync(new ReadResourceHistoryRequest { ResourceId = "SOMEFHIRCONFORMID", ResourceType = "Observation" }); Assert.AreEqual(ResponseCode.ResourceNotFound, response.Code); }
public FhirController( CreateResourceInteractor createResourceInteractor, ReadResourceInteractor readResourceInteractor, GetCapabilitiesInteractor capabilitiesInteractor, ValidateResourceInteractor validateResourceInteractor, SearchResourcesInteractor searchResourcesInteractor, ReadResourceVersionInteractor readResourceVersionInteractor, ReadResourceHistoryInteractor readResourceHistoryInteractor, DeleteResourceInteractor deleteResourceInteractor) { this.CreateResourceInteractor = createResourceInteractor; this.ReadResourceInteractor = readResourceInteractor; this.CapabilitiesInteractor = capabilitiesInteractor; this.ValidateResourceInteractor = validateResourceInteractor; this.SearchResourcesInteractor = searchResourcesInteractor; this.ReadResourceVersionInteractor = readResourceVersionInteractor; this.ReadResourceHistoryInteractor = readResourceHistoryInteractor; this.DeleteResourceInteractor = deleteResourceInteractor; }
public async Task TestResourceExistsShouldReturnResourceAndSuccess() { var resource = FhirResourceProvider.Patient; resource.Id = "SOMEFHIRCONFORMID"; resource.Meta = new Meta { LastUpdated = DateTimeOffset.UtcNow }; var repository = new InMemoryFhirRepository(); repository.Resources.Add(resource); var interactor = new ReadResourceHistoryInteractor(repository); var response = await interactor.ExecuteAsync(new ReadResourceHistoryRequest { ResourceId = "SOMEFHIRCONFORMID", ResourceType = "Patient" }); Assert.AreEqual(ResponseCode.Success, response.Code); var bundleComponent = ((Bundle)response.Resource).Entry.First(); Assert.IsTrue(bundleComponent.Resource.IsExactly(resource)); Assert.AreEqual(Bundle.HTTPVerb.POST, bundleComponent.Request.Method); Assert.AreEqual(resource.Meta.LastUpdated.Value.Millisecond, bundleComponent.Response.LastModified.Value.Millisecond); }
public GlucoseController(SearchResourcesInteractor searchResourcesInteractor, ReadResourceHistoryInteractor readResourceHistoryInteractor) { this.SearchResourcesInteractor = searchResourcesInteractor; this.ReadResourceHistoryInteractor = readResourceHistoryInteractor; this.Cache = new SqlLiteGlucoseCache(); }