public async void GivenValidDeviceIdentifierWhenDefaultSystemSet_WhenResolveResourceIdentitiesAsync_ThenDeviceAndPatientIdReturned_Test() { var fhirClient = Substitute.For <IFhirClient>(); var resourceService = Substitute.For <ResourceManagementService>(); var device = new Model.Device { Id = "1", Patient = new Model.ResourceReference("Patient/123"), }; var mg = Substitute.For <IMeasurementGroup>(); mg.DeviceId.Returns("deviceId"); var options = new ResourceIdentityOptions { DefaultDeviceIdentifierSystem = "mySystem", }; resourceService.GetResourceByIdentityAsync <Model.Device>(Arg.Any <IFhirClient>(), Arg.Any <string>(), Arg.Any <string>()) .Returns(Task.FromResult(device)); using (var idSrv = new R4DeviceAndPatientLookupIdentityService(fhirClient, resourceService)) { idSrv.Initialize(options); var ids = await idSrv.ResolveResourceIdentitiesAsync(mg); Assert.Equal("1", ids[ResourceType.Device]); Assert.Equal("123", ids[ResourceType.Patient]); } await resourceService.Received(1).GetResourceByIdentityAsync <Model.Device>(fhirClient, "deviceId", "mySystem"); }
public void GivenValidConfigurationAndNoCtorParams_WhenCreate_ThenObjectCreated_Test() { var options = new ResourceIdentityOptions { ResourceIdentityServiceType = nameof(Test1ResourceIdentityService) }; var srv = ResourceIdentityServiceFactory.Instance.Create(options); Assert.NotNull(srv); var typedSrv = Assert.IsType <Test1ResourceIdentityService>(srv); Assert.Equal(options, typedSrv.Options); }
public void GivenLegacySupportedConfigurationAndNoCtorParams_WhenLookup_ThenObjectCreated_Test() { var options = new ResourceIdentityOptions { ResourceIdentityServiceType = "R4DeviceAndPatientLookupIdentityService" }; var srv = ResourceIdentityServiceFactory.Instance.Create(options); Assert.NotNull(srv); var typedSrv = Assert.IsType <TestLookupResourceIdentityService>(srv); Assert.Equal(options, typedSrv.Options); }
public void GivenSupportedConfigurationAndValidCtorParams_WhenCreate_ThenObjectCreatedWithParam_Test() { var options = new ResourceIdentityOptions { ResourceIdentityServiceType = "Create" }; var srv = ResourceIdentityServiceFactory.Instance.Create(options, "foo"); Assert.NotNull(srv); var typedSrv = Assert.IsType <TestCreateResourceIdentityService>(srv); Assert.Equal("foo", typedSrv.Parameter); Assert.Equal(options, typedSrv.Options); }
public void Initialize(ResourceIdentityOptions options) { _options = EnsureArg.IsNotNull(options); }
public void Initialize(ResourceIdentityOptions options) { Options = options; }