public async Task GivenASystemConformanceProvider_WhenRequestingACapabilitiesDocument_ThenGetsAValidCapabilityStatement() { SystemConformanceProvider systemCapabilities = CreateSystemConformanceProvider(); var capabilityStatement = await systemCapabilities.GetSystemListedCapabilitiesStatementAsync(); Assert.NotNull(capabilityStatement.Software); Assert.Equal("Microsoft FHIR Server", capabilityStatement.Software.Name); Assert.Equal("Microsoft Corporation", capabilityStatement.Publisher); Assert.NotNull(capabilityStatement.Rest.Single().Resource.Single().Interaction.FirstOrDefault(x => x.Code == CapabilityStatement.TypeRestfulInteraction.Create)); Assert.Equal(ResourceIdentity.Core(FHIRAllTypes.Account).AbsoluteUri, capabilityStatement.Rest.Single().Resource.Single().Profile.Url.ToString()); }
private static SystemConformanceProvider CreateSystemConformanceProvider() { var createCapability = Substitute.For <IProvideCapability>(); createCapability .When(x => x.Build(Arg.Any <ListedCapabilityStatement>())) .Do(callback => callback.ArgAt <ListedCapabilityStatement>(0).TryAddRestInteraction(ResourceType.Account, CapabilityStatement.TypeRestfulInteraction.Create) .TryAddRestInteraction(ResourceType.Account, CapabilityStatement.TypeRestfulInteraction.Read) .TryAddRestInteraction(ResourceType.Account, CapabilityStatement.TypeRestfulInteraction.Vread)); var owned = Substitute.For <IScoped <IEnumerable <IProvideCapability> > >(); owned.Value.Returns(new[] { createCapability }); var systemCapabilities = new SystemConformanceProvider(() => owned); return(systemCapabilities); }
public async Task GivenMultipleProviders_WhenRequestingAMergedCapabilitiesDocument_ThenGetsAValidCapabilityStatement() { SystemConformanceProvider systemCapabilities = CreateSystemConformanceProvider(); var mockedCapabilities = CapabilityStatementMock.GetMockedCapabilityStatement(); CapabilityStatementMock.SetupMockResource(mockedCapabilities, ResourceType.Account, new[] { CapabilityStatement.TypeRestfulInteraction.Create, CapabilityStatement.TypeRestfulInteraction.Read }); var configured = Substitute.For <IConfiguredConformanceProvider>(); configured .GetCapabilityStatementAsync() .Returns(mockedCapabilities.ToResourceElement()); var urlResolver = Substitute.For <IUrlResolver>(); urlResolver.ResolveMetadataUrl(Arg.Any <bool>()).Returns(new Uri("http://localhost/metadata")); var config = new ConformanceConfiguration() { UseStrictConformance = true, }; var provider = new ConformanceProvider( systemCapabilities, configured, urlResolver, Options.Create(config)); var typedCapabilityStatement = await provider.GetCapabilityStatementAsync(); var capabilityStatement = typedCapabilityStatement.ToPoco <CapabilityStatement>(); Assert.NotNull(capabilityStatement.Software); Assert.Equal("Microsoft FHIR Server", capabilityStatement.Software.Name); Assert.Equal("Microsoft Corporation", capabilityStatement.Publisher); Assert.NotNull(capabilityStatement.Rest.Single().Resource.Single().Interaction.FirstOrDefault(x => x.Code == CapabilityStatement.TypeRestfulInteraction.Create)); Assert.NotNull(capabilityStatement.Rest.Single().Resource.Single().Interaction.FirstOrDefault(x => x.Code == CapabilityStatement.TypeRestfulInteraction.Read)); }