예제 #1
0
        public TestContext(WebApplicationFactory <Startup> factory)
        {
            _webFactory = factory;

            _testSupportConfigurationOptions = GetTestSupportConfigurationOptions();

            MockServer = SetupMockedServer();

            HttpClient = SetupApiClient();
        }
예제 #2
0
        private TestSupportOptions GetTestSupportConfigurationOptions()
        {
            TestSupportOptions options = new TestSupportOptions();

            IConfigurationRoot config = new ConfigurationBuilder()
                                        .SetBasePath(AppContext.BaseDirectory)
                                        .AddJsonFile("appsettings.json", false, true)
                                        .Build();

            config.GetSection(nameof(TestSupportOptions)).Bind(options);

            if (string.IsNullOrEmpty(options.ApiClientUrl) || string.IsNullOrEmpty(options.ServerMockUrl))
            {
                throw new ConfigurationErrorsException($"Invalid configuration in appsettings json file");
            }

            return(options);
        }