Forcing the host to restart in specflow

This commit is contained in:
Sebastien Ros
2014-05-16 16:53:39 -07:00
parent dcbd6e3d17
commit 34575b1732
4 changed files with 17 additions and 15 deletions

View File

@@ -59,6 +59,11 @@ namespace Orchard.Specs.Bindings {
descriptor.Features.Concat(new[] { new ShellFeature { Name = name } }),
descriptor.Parameters);
}
// this is needed to force the tenant to restart when a new feature is enabled,
// as DefaultOrchardHost maintains this list in a thread context otherwise
// and looses the information
MvcApplication.RestartTenant("Default");
});
}

View File

@@ -40,14 +40,24 @@ namespace Orchard.Specs.Hosting.Orchard.Web {
builder.Register(ctx => RouteTable.Routes).SingleInstance();
builder.Register(ctx => ModelBinders.Binders).SingleInstance();
builder.Register(ctx => ViewEngines.Engines).SingleInstance();
builder.RegisterType<SpecHostEnvironment>().As<IHostEnvironment>();
}
public static void ReloadExtensions() {
_host.ReloadExtensions();
}
public static void RestartTenant(string name) {
var settings = _container.Resolve<IShellSettingsManager>().LoadSettings().SingleOrDefault(x => x.Name == name);
if (settings == null) {
settings = new ShellSettings {
Name = name,
State = TenantState.Uninitialized
};
}
((DefaultOrchardHost)_host).ActivateShell(settings);
}
public static IWorkContextScope CreateStandaloneEnvironment(string name) {
var settings = _container.Resolve<IShellSettingsManager>().LoadSettings().SingleOrDefault(x => x.Name == name);
if (settings == null) {

View File

@@ -1,12 +0,0 @@
using Orchard.Environment;
namespace Orchard.Specs.Hosting {
public class SpecHostEnvironment : HostEnvironment {
public SpecHostEnvironment() {
}
public override void RestartAppDomain() {
// do nothing
}
}
}

View File

@@ -171,7 +171,6 @@
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
</Compile>
<Compile Include="Hosting\SpecHostEnvironment.cs" />
<Compile Include="Input.feature.cs">
<DependentUpon>Input.feature</DependentUpon>
<AutoGen>True</AutoGen>