Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Simplifying MvcTestFixture #3796

Merged
merged 1 commit into from
Dec 21, 2015
Merged

Simplifying MvcTestFixture #3796

merged 1 commit into from
Dec 21, 2015

Conversation

pranavkm
Copy link
Contributor

No description provided.

@pranavkm
Copy link
Contributor Author

cc @davidfowl \ @JunTaoLuo

@@ -89,6 +57,7 @@ protected virtual void AddAdditionalServices(IServiceCollection services)
// points to the root folder of the test project.
// To compensate, we need to calculate the correct project path and override the application
// environment value so that components like the view engine work properly in the context of the test.
var startupAssembly = typeof(TStartup).GetTypeInfo().Assembly;
var applicationName = startupAssembly.GetName().Name;
var library = libraryManager.GetLibrary(applicationName);
var applicationRoot = Path.GetDirectoryName(library.Path);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to reset the hostingEnvironment still? Doesn't it rebase itself on the new app base?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't checked. Let me verify.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. Removed

@pranavkm pranavkm force-pushed the prkrishn/MvcTestFixture branch from 4f5bdc7 to f56cf97 Compare December 20, 2015 05:59
.ConfigureServices(
services => InitializeServices(startupTypeInfo.Assembly, services, configureServices));
.ConfigureServices(InitializeServices)
.UseStartup(typeof(TStartup));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: UseStartup<TStartup>()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I end up having to annotate TStartup : new(). It's less code this way :)

@davidfowl
Copy link
Member

Looks good besides CI failure?

@rynowak
Copy link
Member

rynowak commented Dec 21, 2015

@pranavkm - this is super nice cleanup.

The other part of this item... what else would a user need to do to integration test their site? What tasks is the fixture currently performing that the hosting builder is not performing? (Ignore things like test logger and test encoder, which our users probably don't care about by default).

@davidfowl
Copy link
Member

@rynowak setting the app base is the main one. If we override that by handling it at the IApplicationEnvironment layer then AppContext.BaseDirectory won't work but maybe that's fine and we don't care?

@pranavkm
Copy link
Contributor Author

The StaticAssemblyProvider bit is also something a user would need to setup. If we change Mvc to not perform controller discovery and instead use a list provided at startup, this would go away.

AppContext.BaseDirectory won't work but maybe that's fine and we don't care?

That seems fine to me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants