Esempio n. 1
0
        protected TestHostingServer(string solutionRelativePath)
        {
            var startupAssembly = typeof(TStartup).GetTypeInfo().Assembly;
            var contentRoot     = SolutionPathUtility.GetProjectPath(solutionRelativePath, startupAssembly);

            var builder = new WebHostBuilder()
                          .UseContentRoot(contentRoot)
                          .ConfigureServices(InitializeServices)
                          .UseEnvironment(EnvironmentName.Development)
                          .UseUrls("http://*:5005")
                          .UseStartup(typeof(TStartup));

            _server            = new TestServer(builder);
            Client             = _server.CreateClient();
            Client.BaseAddress = new Uri("http://localhost:5005");
        }
Esempio n. 2
0
        protected MvcTestFixture(string solutionRelativePath)
        {
            // RequestLocalizationOptions saves the current culture when constructed, potentially changing response
            // localization i.e. RequestLocalizationMiddleware behavior. Ensure the saved culture
            // (DefaultRequestCulture) is consistent regardless of system configuration or personal preferences.
            using (new CultureReplacer())
            {
                var startupAssembly = typeof(TStartup).GetTypeInfo().Assembly;
                var contentRoot     = SolutionPathUtility.GetProjectPath(solutionRelativePath, startupAssembly);

                var builder = new WebHostBuilder()
                              .UseContentRoot(contentRoot)
                              .ConfigureServices(InitializeServices)
                              .UseStartup(typeof(TStartup));

                _server = new TestServer(builder);
            }

            Client             = _server.CreateClient();
            Client.BaseAddress = new Uri("http://localhost");
        }