mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-03 12:03:51 +08:00
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:
@@ -32,7 +32,12 @@ namespace Orchard.Specs.Bindings {
|
|||||||
|
|
||||||
[Given(@"I have installed ""(.*)\""")]
|
[Given(@"I have installed ""(.*)\""")]
|
||||||
public void GivenIHaveInstalled(string name) {
|
public void GivenIHaveInstalled(string name) {
|
||||||
Binding<WebAppHosting>().GivenIHaveModule(name);
|
var webApp = Binding<WebAppHosting>();
|
||||||
|
webApp.GivenIHaveModule(name);
|
||||||
|
webApp.Host.Execute(() => {
|
||||||
|
MvcApplication.ReloadExtensions();
|
||||||
|
});
|
||||||
|
|
||||||
GivenIHaveEnabled(name);
|
GivenIHaveEnabled(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
using System;
|
using System.Linq;
|
||||||
using System.Linq;
|
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using System.Web.Routing;
|
using System.Web.Routing;
|
||||||
using Autofac;
|
using Autofac;
|
||||||
using Autofac.Integration.Web;
|
|
||||||
using Orchard.Environment;
|
using Orchard.Environment;
|
||||||
using Orchard.Environment.Configuration;
|
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" });
|
var route = RouteTable.Routes.MapRoute("foo", "hello-world", new { controller = "Home", action = "Index" });
|
||||||
route.RouteHandler = new HelloYetAgainHandler();
|
route.RouteHandler = new HelloYetAgainHandler();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void Application_BeginRequest() {
|
protected void Application_BeginRequest() {
|
||||||
@@ -43,6 +40,10 @@ namespace Orchard.Specs.Hosting.Orchard.Web {
|
|||||||
get { return _host; }
|
get { return _host; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void ReloadExtensions() {
|
||||||
|
_host.ReloadExtensions();
|
||||||
|
}
|
||||||
|
|
||||||
public static IStandaloneEnvironment CreateStandaloneEnvironment(string name) {
|
public static IStandaloneEnvironment CreateStandaloneEnvironment(string name) {
|
||||||
var settings = _hostContainer.Resolve<IShellSettingsManager>().LoadSettings().SingleOrDefault(x => x.Name == name);
|
var settings = _hostContainer.Resolve<IShellSettingsManager>().LoadSettings().SingleOrDefault(x => x.Name == name);
|
||||||
return Host.CreateStandaloneEnvironment(settings);
|
return Host.CreateStandaloneEnvironment(settings);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ Scenario: Media admin is available
|
|||||||
And I have installed "Orchard.Media"
|
And I have installed "Orchard.Media"
|
||||||
When I go to "admin/media"
|
When I go to "admin/media"
|
||||||
Then I should see "Manage Media Folders"
|
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
|
Scenario: Creating a folder
|
||||||
Given I have installed Orchard
|
Given I have installed Orchard
|
||||||
@@ -21,5 +21,4 @@ Scenario: Creating a folder
|
|||||||
And I am redirected
|
And I am redirected
|
||||||
Then I should see "Manage Media Folders"
|
Then I should see "Manage Media Folders"
|
||||||
And I should see "Hello World"
|
And I should see "Hello World"
|
||||||
And the status should be 200 OK
|
And the status should be 200 OK
|
||||||
|
|
||||||
|
|||||||
36
src/Orchard.Specs/Media.feature.cs
generated
36
src/Orchard.Specs/Media.feature.cs
generated
@@ -1,18 +1,21 @@
|
|||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// This code was generated by SpecFlow (http://www.specflow.org/).
|
// This code was generated by SpecFlow (http://www.specflow.org/).
|
||||||
// SpecFlow Version:1.2.0.0
|
// SpecFlow Version:1.3.2.0
|
||||||
// Runtime Version:2.0.50727.4927
|
// Runtime Version:4.0.30319.1
|
||||||
//
|
//
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
// the code is regenerated.
|
// the code is regenerated.
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
|
#region Designer generated code
|
||||||
namespace Orchard.Specs
|
namespace Orchard.Specs
|
||||||
{
|
{
|
||||||
using TechTalk.SpecFlow;
|
using TechTalk.SpecFlow;
|
||||||
|
|
||||||
|
|
||||||
|
[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.3.2.0")]
|
||||||
|
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
[NUnit.Framework.TestFixtureAttribute()]
|
[NUnit.Framework.TestFixtureAttribute()]
|
||||||
[NUnit.Framework.DescriptionAttribute("Media management")]
|
[NUnit.Framework.DescriptionAttribute("Media management")]
|
||||||
public partial class MediaManagementFeature
|
public partial class MediaManagementFeature
|
||||||
@@ -58,15 +61,15 @@ namespace Orchard.Specs
|
|||||||
#line 6
|
#line 6
|
||||||
this.ScenarioSetup(scenarioInfo);
|
this.ScenarioSetup(scenarioInfo);
|
||||||
#line 7
|
#line 7
|
||||||
testRunner.Given("I have installed Orchard");
|
testRunner.Given("I have installed Orchard");
|
||||||
#line 8
|
#line 8
|
||||||
testRunner.And("I have installed \"Orchard.Media\"");
|
testRunner.And("I have installed \"Orchard.Media\"");
|
||||||
#line 9
|
#line 9
|
||||||
testRunner.When("I go to \"admin/media\"");
|
testRunner.When("I go to \"admin/media\"");
|
||||||
#line 10
|
#line 10
|
||||||
testRunner.Then("I should see \"Manage Media Folders\"");
|
testRunner.Then("I should see \"Manage Media Folders\"");
|
||||||
#line 11
|
#line 11
|
||||||
testRunner.And("the status should be 200 OK");
|
testRunner.And("the status should be 200 OK");
|
||||||
#line hidden
|
#line hidden
|
||||||
testRunner.CollectScenarioErrors();
|
testRunner.CollectScenarioErrors();
|
||||||
}
|
}
|
||||||
@@ -79,11 +82,11 @@ this.ScenarioSetup(scenarioInfo);
|
|||||||
#line 13
|
#line 13
|
||||||
this.ScenarioSetup(scenarioInfo);
|
this.ScenarioSetup(scenarioInfo);
|
||||||
#line 14
|
#line 14
|
||||||
testRunner.Given("I have installed Orchard");
|
testRunner.Given("I have installed Orchard");
|
||||||
#line 15
|
#line 15
|
||||||
testRunner.And("I have installed \"Orchard.Media\"");
|
testRunner.And("I have installed \"Orchard.Media\"");
|
||||||
#line 16
|
#line 16
|
||||||
testRunner.When("I go to \"admin/media/create\"");
|
testRunner.When("I go to \"admin/media/create\"");
|
||||||
#line hidden
|
#line hidden
|
||||||
TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] {
|
TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] {
|
||||||
"name",
|
"name",
|
||||||
@@ -92,19 +95,20 @@ this.ScenarioSetup(scenarioInfo);
|
|||||||
"Name",
|
"Name",
|
||||||
"Hello World"});
|
"Hello World"});
|
||||||
#line 17
|
#line 17
|
||||||
testRunner.And("I fill in", ((string)(null)), table1);
|
testRunner.And("I fill in", ((string)(null)), table1);
|
||||||
#line 20
|
#line 20
|
||||||
testRunner.And("I hit \"Save\"");
|
testRunner.And("I hit \"Save\"");
|
||||||
#line 21
|
#line 21
|
||||||
testRunner.And("I am redirected");
|
testRunner.And("I am redirected");
|
||||||
#line 22
|
#line 22
|
||||||
testRunner.Then("I should see \"Manage Media Folders\"");
|
testRunner.Then("I should see \"Manage Media Folders\"");
|
||||||
#line 23
|
#line 23
|
||||||
testRunner.And("I should see \"Hello World\"");
|
testRunner.And("I should see \"Hello World\"");
|
||||||
#line 24
|
#line 24
|
||||||
testRunner.And("the status should be 200 OK");
|
testRunner.And("the status should be 200 OK");
|
||||||
#line hidden
|
#line hidden
|
||||||
testRunner.CollectScenarioErrors();
|
testRunner.CollectScenarioErrors();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|||||||
@@ -66,6 +66,10 @@ namespace Orchard.Environment {
|
|||||||
BuildCurrent();
|
BuildCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IOrchardHost.ReloadExtensions() {
|
||||||
|
_current = null;
|
||||||
|
BuildCurrent();
|
||||||
|
}
|
||||||
|
|
||||||
void IOrchardHost.BeginRequest() {
|
void IOrchardHost.BeginRequest() {
|
||||||
Logger.Debug("BeginRequest");
|
Logger.Debug("BeginRequest");
|
||||||
|
|||||||
@@ -8,6 +8,12 @@ namespace Orchard.Environment {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
void Initialize();
|
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>
|
/// <summary>
|
||||||
/// Called each time a request begins to offer a just-in-time reinitialization point
|
/// Called each time a request begins to offer a just-in-time reinitialization point
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -23,5 +29,5 @@ namespace Orchard.Environment {
|
|||||||
/// Services may be resolved from within this instance to configure and initialize it's storage.
|
/// Services may be resolved from within this instance to configure and initialize it's storage.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
IStandaloneEnvironment CreateStandaloneEnvironment(ShellSettings shellSettings);
|
IStandaloneEnvironment CreateStandaloneEnvironment(ShellSettings shellSettings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user