-
Notifications
You must be signed in to change notification settings - Fork 311
Is there a way to parameterize and pass an instance of Startup rather than just the type? #333
Comments
How about the |
These overloads are limited - It wont work because
Instead of trying to draw two parallels - using StartUp class and StartUpMethods and having supported UseStartUp extension method, IMHO - it will be simple and easy to just start support taking an instance of StartUp thats got environment specific configuration as state in it. |
and this is what I have to do to keep it working - right now
Doesn't feel good! any suggestions? |
Just to clarify the scenario you are trying to accomplish, you mostly want a way to configure a test to run with specific configuration (i.e. just tweak the configuration per test?) |
that is right, I would prefer to keep the same startup while injecting a different configuration compared to having two startup files or having conditions in the start up file. |
Moving this to Backlog as we will be in RC2 ask mode very soon. If you feel strongly about this issue, please ping me. |
Fixed with 8f5f8d2 which is post RC2. You can add an |
PS: it would look like this: Startup instanceOfStartup= new Startup();
instanceOfStartup.Configuration = myOwnconfigurationWithKeysRequiredForTest;
//create a test server with
var builder = new WebHostBuilder()
.ConfigureServices(services =>
{
services.AddSingleton<IStartup>(instanceOfStartup);
});
var server = new TestServer(builder); |
And here's a nice blog post about the new |
From @humblelistener on August 14, 2015 5:8
The intention is to avoid creating a separate TestStartUp class rather - rather inject an instance of Configuration
Sample start up below,
In the above implementation, if only
TestServer.CreateBuilder().UseStartup(instanceOfStartup)
is permitted
I can do this,
Advantage: I dont have to maintain multiple startup class.
Does it make sense?
Copied from original issue: dotnet/aspnetcore#831
The text was updated successfully, but these errors were encountered: