Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to parameterize and pass an instance of Startup rather than just the type? #831

Closed
humblelistener opened this issue Aug 14, 2015 · 1 comment

Comments

@humblelistener
Copy link

The intention is to avoid creating a separate TestStartUp class rather - rather inject an instance of Configuration

Sample start up below,

public class Startup
{
  public IConfiguration Configuration {get; set;}

  public void Startup()
  {
    Configuration = new ConfigurationBuilder()
              .AddEnvironmentVariables()
              .Build();
   }

  public void ConfigureServices(IServiceCollection services)
  {
     //uses Configuration object to set up everything
  }
}

In the above implementation, if only

TestServer.CreateBuilder().UseStartup(instanceOfStartup)
is permitted

I can do this,

Startup instanceOfStartup= new Startup();
instanceOfStartup.Configuration = myOwnconfigurationWithKeysRequiredForTest;
//create a test server with 
TestServer.CreateBuilder().UseStartup(instanceOfStartup) 

Advantage: I dont have to maintain multiple startup class.

Does it make sense?

@Tratcher
Copy link
Member

This issue was moved to aspnet/Hosting#333

natemcmaster pushed a commit that referenced this issue Nov 20, 2018
…e in Common

[Fixes #831] Fix startup exception page to handle flattened exceptions
@ghost ghost locked as resolved and limited conversation to collaborators Dec 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants