Exemplo n.º 1
0
        private TestServer StartMainServer(ServerFixtureConfiguration fixtureConfiguration)
        {
            var wrappedStartupType = typeof(MainServiceStartup <>).MakeGenericType(fixtureConfiguration.StartupType);

            var host = new WebHostBuilder()
                       .UseEnvironment("Test")
                       .ConfigureAppConfiguration((context, configuration) =>
            {
                configuration.SetBasePath(Directory.GetCurrentDirectory());
                fixtureConfiguration.MainServicePostAppConfiguration?.Invoke(configuration, _testContext);
            })
                       .ConfigureLogging((context, logger) =>
            {
                logger.AddProvider(new XunitLoggerProvider(_testContext.Output));
            })
                       .ConfigureServices(services =>
            {
                services.AddSingleton <ServerFixtureConfiguration>(fixtureConfiguration);
                services.AddSingleton <ServerFixture>(this);
            })
                       .UseKestrel()
                       .UseContentRoot(Directory.GetCurrentDirectory())
                       .UseStartup(wrappedStartupType);

            return(new TestServer(host));
        }
Exemplo n.º 2
0
 public ServerFixture(ServerFixtureConfiguration fixtureConfiguration, TestContext testContext)
 {
     _fixtureConfiguration = fixtureConfiguration;
     _testContext          = testContext;
     _server = StartMainServer(_fixtureConfiguration);
 }
Exemplo n.º 3
0
 public ServerFixture CreateServerFixture(ServerFixtureConfiguration serverConfiguration)
 {
     return(new ServerFixture(serverConfiguration, TestContext));
 }