Fixing more tests

Default Orchard host tests provides test components explicitly for resolving
Simple hosting tests use site in it's own basic folder

--HG--
branch : dev
This commit is contained in:
Louis DeJardin
2010-04-20 16:11:48 -07:00
parent a03f0278f7
commit 5a07a5a8c4
14 changed files with 305 additions and 52 deletions

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
@@ -23,8 +22,14 @@ namespace Orchard.Specs.Bindings {
[Given(@"I have a clean site")]
public void GivenIHaveACleanSite() {
GivenIHaveACleanSiteBasedOn("Orchard.Web");
}
[Given(@"I have a clean site based on (.*)")]
public void GivenIHaveACleanSiteBasedOn(string siteFolder) {
_webHost = new WebHost();
_webHost.Initialize("Orchard.Web", "/");
_webHost.Initialize(siteFolder, "/");
var sink = new MessageSink();
_webHost.Execute(() => {
@@ -33,15 +38,6 @@ namespace Orchard.Specs.Bindings {
_messages = sink;
}
public class MessageSink : MarshalByRefObject {
readonly IList<string> _messages = new List<string>();
public void Receive(string message) {
_messages.Add(message);
}
}
[Given(@"I have module ""(.*)""")]
public void GivenIHaveModule(string moduleName) {
_webHost.CopyExtension("Modules", moduleName);

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
namespace Orchard.Specs.Hosting {
public class MessageSink : MarshalByRefObject {
readonly IList<string> _messages = new List<string>();
public void Receive(string message) {
_messages.Add(message);
}
}
}

View File

@@ -0,0 +1 @@
<%@ Application Inherits="Orchard.Specs.Hosting.Simple.Web.MvcApplication, Orchard.Specs" %>

View File

@@ -0,0 +1,22 @@
using System;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Autofac;
using Autofac.Integration.Web;
using Orchard.Environment;
using Orchard.Specs.Hosting.Orchard.Web;
namespace Orchard.Specs.Hosting.Simple.Web {
public class MvcApplication : HttpApplication
{
protected void Application_Start()
{
var route = RouteTable.Routes.MapRoute("foo", "hello-world", new { controller = "Home", action = "Index" });
route.RouteHandler = new HelloYetAgainHandler();
}
}
}

View File

@@ -0,0 +1,169 @@
<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
<appSettings/>
<!--
Set default transaction timeout to 30 minutes so that interactive debugging
is easier (default timeout is less than one minute)
-->
<system.transactions>
<defaultSettings timeout="00:30:00" />
</system.transactions>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</assemblies>
</compilation>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Forms">
<forms loginUrl="~/Users/Account/AccessDenied" timeout="2880" />
</authentication>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
-->
<customErrors mode="Off" />
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
<namespaces>
<add namespace="System.Web.Mvc"/>
<add namespace="System.Web.Mvc.Ajax"/>
<add namespace="System.Web.Mvc.Html"/>
<add namespace="System.Web.Routing"/>
<add namespace="System.Linq"/>
<add namespace="System.Collections.Generic"/>
</namespaces>
</pages>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
<add verb="*" path="*.mvc" validate="false" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</httpModules>
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4"
type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4"
type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="OptionInfer" value="true"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
</compilers>
</system.codedom>
<system.web.extensions/>
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0. It is not necessary for previous version of IIS.
-->
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true">
<remove name="ScriptModule" />
<remove name="UrlRoutingModule" />
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<remove name="ScriptHandlerFactory" />
<remove name="ScriptHandlerFactoryAppServices" />
<remove name="ScriptResource" />
<remove name="MvcHttpHandler" />
<remove name="UrlRoutingHandler" />
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="MvcHttpHandler" preCondition="integratedMode" verb="*" path="*.mvc" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@@ -86,10 +86,12 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Hosting\MessageSink.cs" />
<Compile Include="Hosting\HostingTraceListener.cs" />
<Compile Include="Hosting\Orchard.Web\HelloYetAgainHandler.cs" />
<Compile Include="Hosting\Simple.Web\HelloYetAgainHandler.cs" />
<Compile Include="Hosting\RequestExtensions.cs" />
<Compile Include="Hosting\RequestDetails.cs" />
<Compile Include="Hosting\Simple.Web\Global.asax.cs" />
<Compile Include="Util\PathExtensions.cs" />
<Compile Include="WebHosting.feature.cs">
<DependentUpon>WebHosting.feature</DependentUpon>
@@ -130,6 +132,9 @@
<None Include="Hosting\Orchard.Web\Config\Diagnostics.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Content Include="Hosting\Simple.Web\Web.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="WebHosting.feature">
<Generator>SpecFlowSingleFileGenerator</Generator>
<LastGenOutput>WebHosting.feature.cs</LastGenOutput>
@@ -205,7 +210,7 @@
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<Content Include="Hosting\Orchard.Web\Content\Static.txt">
<Content Include="Hosting\Simple.Web\Content\Static.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Hosting\Orchard.Web\Default.aspx">
@@ -214,10 +219,13 @@
<Content Include="Hosting\Orchard.Web\Global.asax">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Hosting\Orchard.Web\Simple\Page.aspx">
<Content Include="Hosting\Simple.Web\Global.asax">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Hosting\Orchard.Web\Static.txt">
<Content Include="Hosting\Simple.Web\Simple\Page.aspx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Hosting\Simple.Web\Static.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>

View File

@@ -4,49 +4,49 @@
I want to verify basic hosting is working
Scenario: Returning static files
Given I have a clean site
Given I have a clean site based on Simple.Web
When I go to "Content/Static.txt"
Then the status should be 200 OK
And I should see "Hello world!"
Then I should see "Hello world!"
And the status should be 200 OK
Scenario: Returning static files 2
Given I have a clean site
Given I have a clean site based on Simple.Web
When I go to "Content\Static.txt"
Then the status should be 200 OK
And I should see "Hello world!"
Scenario: Returning static files 3
Given I have a clean site
Given I have a clean site based on Simple.Web
When I go to "/Static.txt"
Then the status should be 200 OK
And I should see "Hello world!"
Scenario: Returning static files 4
Given I have a clean site
Given I have a clean site based on Simple.Web
When I go to "Static.txt"
Then the status should be 200 OK
And I should see "Hello world!"
Scenario: Returning web forms page
Given I have a clean site
Given I have a clean site based on Simple.Web
When I go to "Simple/Page.aspx"
Then the status should be 200 OK
And I should see "Hello again"
Then I should see "Hello again"
And the status should be 200 OK
Scenario: Returning web forms page 2
Given I have a clean site
Given I have a clean site based on Simple.Web
When I go to "Simple\Page.aspx"
Then the status should be 200 OK
And I should see "Hello again"
Scenario: Returning a routed request
Given I have a clean site
Given I have a clean site based on Simple.Web
When I go to "hello-world"
Then the status should be 200 OK
And I should see "Hello yet again"
Scenario: Following a link
Given I have a clean site
Given I have a clean site based on Simple.Web
When I go to "/simple/page.aspx"
And I follow "next page"
Then the status should be 200 OK

View File

@@ -2,7 +2,7 @@
// <auto-generated>
// This code was generated by SpecFlow (http://www.specflow.org/).
// SpecFlow Version:1.2.0.0
// Runtime Version:2.0.50727.4200
// Runtime Version:2.0.50727.4927
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -58,13 +58,13 @@ namespace Orchard.Specs
#line 6
this.ScenarioSetup(scenarioInfo);
#line 7
testRunner.Given("I have a clean site");
testRunner.Given("I have a clean site based on Simple.Web");
#line 8
testRunner.When("I go to \"Content/Static.txt\"");
#line 9
testRunner.Then("the status should be 200 OK");
testRunner.Then("I should see \"Hello world!\"");
#line 10
testRunner.And("I should see \"Hello world!\"");
testRunner.And("the status should be 200 OK");
#line hidden
testRunner.CollectScenarioErrors();
}
@@ -77,7 +77,7 @@ this.ScenarioSetup(scenarioInfo);
#line 12
this.ScenarioSetup(scenarioInfo);
#line 13
testRunner.Given("I have a clean site");
testRunner.Given("I have a clean site based on Simple.Web");
#line 14
testRunner.When("I go to \"Content\\Static.txt\"");
#line 15
@@ -96,7 +96,7 @@ this.ScenarioSetup(scenarioInfo);
#line 18
this.ScenarioSetup(scenarioInfo);
#line 19
testRunner.Given("I have a clean site");
testRunner.Given("I have a clean site based on Simple.Web");
#line 20
testRunner.When("I go to \"/Static.txt\"");
#line 21
@@ -115,7 +115,7 @@ this.ScenarioSetup(scenarioInfo);
#line 24
this.ScenarioSetup(scenarioInfo);
#line 25
testRunner.Given("I have a clean site");
testRunner.Given("I have a clean site based on Simple.Web");
#line 26
testRunner.When("I go to \"Static.txt\"");
#line 27
@@ -134,13 +134,13 @@ this.ScenarioSetup(scenarioInfo);
#line 30
this.ScenarioSetup(scenarioInfo);
#line 31
testRunner.Given("I have a clean site");
testRunner.Given("I have a clean site based on Simple.Web");
#line 32
testRunner.When("I go to \"Simple/Page.aspx\"");
#line 33
testRunner.Then("the status should be 200 OK");
testRunner.Then("I should see \"Hello again\"");
#line 34
testRunner.And("I should see \"Hello again\"");
testRunner.And("the status should be 200 OK");
#line hidden
testRunner.CollectScenarioErrors();
}
@@ -153,7 +153,7 @@ this.ScenarioSetup(scenarioInfo);
#line 36
this.ScenarioSetup(scenarioInfo);
#line 37
testRunner.Given("I have a clean site");
testRunner.Given("I have a clean site based on Simple.Web");
#line 38
testRunner.When("I go to \"Simple\\Page.aspx\"");
#line 39
@@ -172,7 +172,7 @@ this.ScenarioSetup(scenarioInfo);
#line 42
this.ScenarioSetup(scenarioInfo);
#line 43
testRunner.Given("I have a clean site");
testRunner.Given("I have a clean site based on Simple.Web");
#line 44
testRunner.When("I go to \"hello-world\"");
#line 45
@@ -191,7 +191,7 @@ this.ScenarioSetup(scenarioInfo);
#line 48
this.ScenarioSetup(scenarioInfo);
#line 49
testRunner.Given("I have a clean site");
testRunner.Given("I have a clean site based on Simple.Web");
#line 50
testRunner.When("I go to \"/simple/page.aspx\"");
#line 51

View File

@@ -46,10 +46,10 @@ namespace Orchard.Tests.Environment {
builder => {
builder.RegisterInstance(new StubShellSettingsLoader()).As<IShellSettingsManager>();
builder.RegisterType<StubContainerProvider>().As<IContainerProvider>().InstancePerLifetimeScope();
builder.RegisterType<DefaultOrchardHost>().As<IOrchardHost>().SingleInstance();
builder.RegisterType<RoutePublisher>().As<IRoutePublisher>();
builder.RegisterType<ModelBinderPublisher>().As<IModelBinderPublisher>();
builder.RegisterType<ShellContextFactory>().As<IShellContextFactory>();
builder.RegisterType<StubExtensionManager>().As<IExtensionManager>();
builder.RegisterInstance(_controllerBuilder);
builder.RegisterInstance(_routeCollection);
builder.RegisterInstance(_modelBinderDictionary);
@@ -62,14 +62,14 @@ namespace Orchard.Tests.Environment {
_lifetime = _container.BeginLifetimeScope();
_container.Mock<IContainerProvider>()
.SetupGet(cp=>cp.ApplicationContainer).Returns(_container);
.SetupGet(cp => cp.ApplicationContainer).Returns(_container);
_container.Mock<IContainerProvider>()
.SetupGet(cp => cp.RequestLifetime).Returns(_lifetime);
_container.Mock<IContainerProvider>()
.Setup(cp => cp.EndRequestLifetime()).Callback(() => _lifetime.Dispose());
_container.Mock<IShellDescriptorManager>()
.Setup(cp => cp.GetShellDescriptor()).Returns(new ShellDescriptor());
.Setup(cp => cp.GetShellDescriptor()).Returns(default(ShellDescriptor));
var temp = Path.GetTempFileName();
File.Delete(temp);
@@ -83,9 +83,47 @@ namespace Orchard.Tests.Environment {
updater.Update(_lifetime);
}
public class StubExtensionManager : IExtensionManager {
public IEnumerable<ExtensionDescriptor> AvailableExtensions() {
var ext = new ExtensionDescriptor { Name = "Orchard.Framework" };
ext.Features = new[] { new FeatureDescriptor { Extension = ext, Name = ext.Name } };
yield return ext;
}
public IEnumerable<Feature> LoadFeatures(IEnumerable<FeatureDescriptor> featureDescriptors) {
foreach (var descriptor in featureDescriptors) {
if (descriptor.Name == "Orchard.Framework") {
yield return new Feature {
Descriptor = descriptor,
ExportedTypes = new[] {
typeof (TestDependency),
typeof (TestSingletonDependency),
typeof (TestTransientDependency),
}
};
}
}
}
public Feature LoadFeature(FeatureDescriptor featureDescriptor) {
throw new NotImplementedException();
}
public IEnumerable<ExtensionEntry> ActiveExtensions_Obsolete() {
throw new NotImplementedException();
}
public void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle) {
throw new NotImplementedException();
}
public void UninstallExtension(string extensionType, string extensionName) {
throw new NotImplementedException();
}
}
public class StubShellSettingsLoader : IShellSettingsManager {
private readonly List<ShellSettings> _shellSettings = new List<ShellSettings>
{new ShellSettings {Name = "testing"}};
private readonly List<ShellSettings> _shellSettings = new List<ShellSettings> { new ShellSettings { Name = "Default" } };
public IEnumerable<ShellSettings> LoadSettings() {
return _shellSettings.AsEnumerable();
@@ -110,6 +148,7 @@ namespace Orchard.Tests.Environment {
public void DifferentShellInstanceShouldBeReturnedAfterEachCreate() {
var host = _lifetime.Resolve<IOrchardHost>();
var runtime1 = host.CreateShell_Obsolete();
host.Reinitialize_Obsolete();
var runtime2 = host.CreateShell_Obsolete();
Assert.That(runtime1, Is.Not.SameAs(runtime2));
}
@@ -119,6 +158,7 @@ namespace Orchard.Tests.Environment {
public void NormalDependenciesShouldBeUniquePerRequestContainer() {
var host = _lifetime.Resolve<IOrchardHost>();
var container1 = host.CreateShellContainer_Obsolete();
host.Reinitialize_Obsolete();
var container2 = host.CreateShellContainer_Obsolete();
var requestContainer1a = container1.BeginLifetimeScope();
var requestContainer1b = container1.BeginLifetimeScope();
@@ -217,7 +257,7 @@ namespace Orchard.Tests.Environment {
public static class TextExtensions {
public static ILifetimeScope CreateShellContainer_Obsolete(this IOrchardHost host) {
return ((DefaultOrchardHost) host)
return ((DefaultOrchardHost)host)
.Current
.Single(x => x.Settings.Name == "Default")
.LifetimeScope;

View File

@@ -39,7 +39,7 @@ namespace Orchard.Tests.Environment.ShellBuilders {
_container.Mock<IShellContainerFactory>()
.Setup(x => x.CreateContainer(settings, topology))
.Returns(shellLifetimeScope );
.Returns(shellLifetimeScope);
_container.Mock<IShellDescriptorManager>()
.Setup(x => x.GetShellDescriptor())
@@ -57,12 +57,17 @@ namespace Orchard.Tests.Environment.ShellBuilders {
}
[Test]
public void NullSettingsReturnsSetupContext() {
var settings = new ShellSettings { Name = "Default" };
public void CreatingSetupContextUsesOrchardSetupFeature() {
var settings = default(ShellSettings);
var descriptor = default(ShellDescriptor);
var topology = new ShellTopology();
_container.Mock<ICompositionStrategy>()
.Setup(x => x.Compose(settings, It.IsAny<ShellDescriptor>()))
.Setup(x => x.Compose(It.IsAny<ShellSettings>(), It.IsAny<ShellDescriptor>()))
.Callback((ShellSettings s, ShellDescriptor d) => {
settings = s;
descriptor = d;
})
.Returns(topology);
_container.Mock<IShellContainerFactory>()
@@ -70,7 +75,7 @@ namespace Orchard.Tests.Environment.ShellBuilders {
.Returns(_container.BeginLifetimeScope("shell"));
var factory = _container.Resolve<IShellContextFactory>();
var context = factory.CreateShellContext(null);
var context = factory.CreateSetupContext();
Assert.That(context.Descriptor.EnabledFeatures, Has.Some.With.Property("Name").EqualTo("Orchard.Setup"));
}