Fix SpecFlow test

When a new module is installed in the host app, explicitly call
"ReloadExtensions" on the host so that the new module is activated.

We need this because some SpecFlow binding talk directly to the host through
remoting, whereas in the real web scenarios, all comunication is done through
"BeingRequest" which is the guy taking care of reloading modules when
they have changed on disk.

--HG--
branch : dev
This commit is contained in:
Renaud Paquay
2010-07-17 10:51:07 -07:00
parent 3bbc0854e6
commit dc6f614be3
6 changed files with 44 additions and 25 deletions

View File

@@ -32,7 +32,12 @@ namespace Orchard.Specs.Bindings {
[Given(@"I have installed ""(.*)\""")]
public void GivenIHaveInstalled(string name) {
Binding<WebAppHosting>().GivenIHaveModule(name);
var webApp = Binding<WebAppHosting>();
webApp.GivenIHaveModule(name);
webApp.Host.Execute(() => {
MvcApplication.ReloadExtensions();
});
GivenIHaveEnabled(name);
}

View File

@@ -1,10 +1,8 @@
using System;
using System.Linq;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Autofac;
using Autofac.Integration.Web;
using Orchard.Environment;
using Orchard.Environment.Configuration;
@@ -20,7 +18,6 @@ namespace Orchard.Specs.Hosting.Orchard.Web {
var route = RouteTable.Routes.MapRoute("foo", "hello-world", new { controller = "Home", action = "Index" });
route.RouteHandler = new HelloYetAgainHandler();
}
protected void Application_BeginRequest() {
@@ -43,6 +40,10 @@ namespace Orchard.Specs.Hosting.Orchard.Web {
get { return _host; }
}
public static void ReloadExtensions() {
_host.ReloadExtensions();
}
public static IStandaloneEnvironment CreateStandaloneEnvironment(string name) {
var settings = _hostContainer.Resolve<IShellSettingsManager>().LoadSettings().SingleOrDefault(x => x.Name == name);
return Host.CreateStandaloneEnvironment(settings);

View File

@@ -8,7 +8,7 @@ Scenario: Media admin is available
And I have installed "Orchard.Media"
When I go to "admin/media"
Then I should see "Manage Media Folders"
And the status should be 200 OK
And the status should be 200 OK
Scenario: Creating a folder
Given I have installed Orchard
@@ -21,5 +21,4 @@ Scenario: Creating a folder
And I am redirected
Then I should see "Manage Media Folders"
And I should see "Hello World"
And the status should be 200 OK
And the status should be 200 OK

View File

@@ -1,18 +1,21 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by SpecFlow (http://www.specflow.org/).
// SpecFlow Version:1.2.0.0
// Runtime Version:2.0.50727.4927
// SpecFlow Version:1.3.2.0
// Runtime Version:4.0.30319.1
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
#region Designer generated code
namespace Orchard.Specs
{
using TechTalk.SpecFlow;
[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.3.2.0")]
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[NUnit.Framework.TestFixtureAttribute()]
[NUnit.Framework.DescriptionAttribute("Media management")]
public partial class MediaManagementFeature
@@ -58,15 +61,15 @@ namespace Orchard.Specs
#line 6
this.ScenarioSetup(scenarioInfo);
#line 7
testRunner.Given("I have installed Orchard");
testRunner.Given("I have installed Orchard");
#line 8
testRunner.And("I have installed \"Orchard.Media\"");
testRunner.And("I have installed \"Orchard.Media\"");
#line 9
testRunner.When("I go to \"admin/media\"");
testRunner.When("I go to \"admin/media\"");
#line 10
testRunner.Then("I should see \"Manage Media Folders\"");
testRunner.Then("I should see \"Manage Media Folders\"");
#line 11
testRunner.And("the status should be 200 OK");
testRunner.And("the status should be 200 OK");
#line hidden
testRunner.CollectScenarioErrors();
}
@@ -79,11 +82,11 @@ this.ScenarioSetup(scenarioInfo);
#line 13
this.ScenarioSetup(scenarioInfo);
#line 14
testRunner.Given("I have installed Orchard");
testRunner.Given("I have installed Orchard");
#line 15
testRunner.And("I have installed \"Orchard.Media\"");
testRunner.And("I have installed \"Orchard.Media\"");
#line 16
testRunner.When("I go to \"admin/media/create\"");
testRunner.When("I go to \"admin/media/create\"");
#line hidden
TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] {
"name",
@@ -92,19 +95,20 @@ this.ScenarioSetup(scenarioInfo);
"Name",
"Hello World"});
#line 17
testRunner.And("I fill in", ((string)(null)), table1);
testRunner.And("I fill in", ((string)(null)), table1);
#line 20
testRunner.And("I hit \"Save\"");
testRunner.And("I hit \"Save\"");
#line 21
testRunner.And("I am redirected");
testRunner.And("I am redirected");
#line 22
testRunner.Then("I should see \"Manage Media Folders\"");
testRunner.Then("I should see \"Manage Media Folders\"");
#line 23
testRunner.And("I should see \"Hello World\"");
testRunner.And("I should see \"Hello World\"");
#line 24
testRunner.And("the status should be 200 OK");
testRunner.And("the status should be 200 OK");
#line hidden
testRunner.CollectScenarioErrors();
}
}
}
#endregion

View File

@@ -66,6 +66,10 @@ namespace Orchard.Environment {
BuildCurrent();
}
void IOrchardHost.ReloadExtensions() {
_current = null;
BuildCurrent();
}
void IOrchardHost.BeginRequest() {
Logger.Debug("BeginRequest");

View File

@@ -8,6 +8,12 @@ namespace Orchard.Environment {
/// </summary>
void Initialize();
/// <summary>
/// Called externally when there is explicit knowledge that the list of installed
/// modules/extensions has changed, and they need to be reloaded.
/// </summary>
void ReloadExtensions();
/// <summary>
/// Called each time a request begins to offer a just-in-time reinitialization point
/// </summary>
@@ -23,5 +29,5 @@ namespace Orchard.Environment {
/// Services may be resolved from within this instance to configure and initialize it's storage.
/// </summary>
IStandaloneEnvironment CreateStandaloneEnvironment(ShellSettings shellSettings);
}
}
}