protected HttpIntegrationTestFixture(string targetProjectParentDirectory)
        {
            SetUpEnvironmentVariables();

            string environmentUrl = Environment.GetEnvironmentVariable("TestEnvironmentUrl");

            if (string.IsNullOrWhiteSpace(environmentUrl))
            {
                environmentUrl = "http://localhost/";

                StartInMemoryServer(targetProjectParentDirectory);

                _messageHandler         = Server.CreateHandler();
                IsUsingInProcTestServer = true;

                // We need to suppress the execution context because there is no boundary between the client and server while using TestServer
                _messageHandler = new SuppressExecutionContextHandler(_messageHandler);
            }
            else
            {
                if (environmentUrl.Last() != '/')
                {
                    environmentUrl = $"{environmentUrl}/";
                }

                _messageHandler = new HttpClientHandler();
            }

            _environmentUrl = environmentUrl;

            HttpClient = CreateHttpClient();

            FhirClient    = new FhirClient(HttpClient, ResourceFormat.Json);
            FhirXmlClient = new Lazy <FhirClient>(() => new FhirClient(HttpClient, ResourceFormat.Xml));
        }
Beispiel #2
0
        protected HttpIntegrationTestFixture(string targetProjectParentDirectory)
        {
            SetUpEnvironmentVariables();

            string environmentUrl = Environment.GetEnvironmentVariable("TestEnvironmentUrl");

            if (string.IsNullOrWhiteSpace(environmentUrl))
            {
                environmentUrl = "http://localhost/";

                StartInMemoryServer(targetProjectParentDirectory);

                _messageHandler         = Server.CreateHandler();
                IsUsingInProcTestServer = true;
            }
            else
            {
                if (environmentUrl.Last() != '/')
                {
                    environmentUrl = $"{environmentUrl}/";
                }

                _messageHandler = new HttpClientHandler();
            }

            _environmentUrl = environmentUrl;

            HttpClient = CreateHttpClient();

            FhirClient    = new FhirClient(HttpClient, ResourceFormat.Json);
            FhirXmlClient = new Lazy <FhirClient>(() => new FhirClient(HttpClient, ResourceFormat.Xml));
        }
        protected HttpIntegrationTestFixture(string targetProjectParentDirectory, DataStore dataStore, Format format)
        {
            _dataStore = dataStore;
            _format    = format;

            SetUpEnvironmentVariables();

            string environmentUrl = string.Empty;

            switch (dataStore)
            {
            case DataStore.CosmosDb:
                environmentUrl = Environment.GetEnvironmentVariable($"TestEnvironmentUrl{Constants.TestEnvironmentVariableVersionSuffix}");
                break;

            case DataStore.SqlServer:
                environmentUrl = Environment.GetEnvironmentVariable($"TestEnvironmentUrl{Constants.TestEnvironmentVariableVersionSuffix}_Sql");
                break;
            }

            if (string.IsNullOrWhiteSpace(environmentUrl))
            {
                environmentUrl = "http://localhost/";

                StartInProcessTestServer(targetProjectParentDirectory, dataStore);

                _messageHandler         = Server.CreateHandler();
                IsUsingInProcTestServer = true;

                // We need to suppress the execution context because there is no boundary between the client and server while using TestServer
                _messageHandler = new SuppressExecutionContextHandler(_messageHandler);
            }
            else
            {
                if (environmentUrl.Last() != '/')
                {
                    environmentUrl = $"{environmentUrl}/";
                }

                _messageHandler = new HttpClientHandler();
            }

            _environmentUrl = environmentUrl;

            HttpClient = CreateHttpClient();

            switch (_format)
            {
            case Format.Json:
                FhirClient = new FhirClient(HttpClient, ResourceFormat.Json);
                break;

            case Format.Xml:
                FhirClient = new FhirClient(HttpClient, ResourceFormat.Xml);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        protected HttpIntegrationTestFixture(string targetProjectParentDirectory)
        {
            SetUpEnvironmentVariables();

            _environmentUrl = Environment.GetEnvironmentVariable("TestEnvironmentUrl");

            if (string.IsNullOrWhiteSpace(_environmentUrl))
            {
                _environmentUrl = "http://localhost/";

                StartInMemoryServer(targetProjectParentDirectory);

                _messageHandler         = _server.CreateHandler();
                IsUsingInProcTestServer = true;
            }
            else
            {
                _messageHandler = new HttpClientHandler();
            }

            HttpClient = new HttpClient(new SessionMessageHandler(_messageHandler))
            {
                BaseAddress = new Uri(_environmentUrl)
            };

            FhirClient    = new FhirClient(HttpClient, ResourceFormat.Json);
            FhirXmlClient = new Lazy <FhirClient>(() => new FhirClient(HttpClient, ResourceFormat.Xml));
        }
        public static async Task <string[]> GetSupportedIdsAsync(CrucibleClient client)
        {
            await client.RefreshConformanceStatementAsync();

            var httpClient = new HttpClient
            {
                BaseAddress = new Uri(TestEnvironmentUrl),
            };

            var fhirClient = new FhirClient(httpClient, ResourceFormat.Json);

            if (fhirClient.SecuritySettings.SecurityEnabled)
            {
                await client.AuthorizeServerAsync(fhirClient.SecuritySettings.AuthorizeUrl, fhirClient.SecuritySettings.TokenUrl);
            }

            var supportedTests = await client.GetSupportedTestsAsync();

            var ids = supportedTests.Where(x => x.Supported).Select(x => x.Id).ToArray();

            return(ids);
        }
Beispiel #6
0
 public ExportDataValidationTests(HttpIntegrationTestFixture fixture, ITestOutputHelper testOutputHelper)
 {
     _fhirClient   = fixture.FhirClient;
     _outputHelper = testOutputHelper;
 }
 internal static void AssertLocationHeaderIsCorrect(FhirClient fhirClient, Resource createdResource, Uri location)
 {
     Assert.Equal($"{fhirClient.HttpClient.BaseAddress}Observation/{createdResource.Id}/_history/{createdResource.Meta.VersionId}", location.OriginalString);
 }
 public VersionSpecificTests(HttpIntegrationTestFixture <Startup> fixture)
 {
     _client = fixture.FhirClient;
 }