Updating Orchard.Spec testing to manage temporary resources a little better

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-11-15 16:13:26 -08:00
parent 07fdaac822
commit dc67d6be9b
3 changed files with 31 additions and 14 deletions

View File

@@ -9,6 +9,7 @@ using log4net.Core;
using NUnit.Framework;
using Orchard.Specs.Hosting;
using TechTalk.SpecFlow;
using Path = Bleroy.FluentPath.Path;
namespace Orchard.Specs.Bindings {
[Binding]
@@ -17,9 +18,7 @@ namespace Orchard.Specs.Bindings {
private RequestDetails _details;
private HtmlDocument _doc;
private MessageSink _messages;
public WebAppHosting() {
}
private static readonly Path _orchardTemp = Path.Get(System.IO.Path.GetTempPath()).Combine("Orchard.Specs");
public WebHost Host {
get { return _webHost; }
@@ -30,6 +29,16 @@ namespace Orchard.Specs.Bindings {
set { _details = value; }
}
[BeforeTestRun]
public static void BeforeTestRun() {
_orchardTemp.Delete(true).CreateDirectory();
}
[AfterTestRun]
public static void AfterTestRun() {
_orchardTemp.Delete(true); // <- try to clear any stragglers on the way out
}
[AfterScenario]
public void AfterScenario() {
if (_webHost != null) {
@@ -46,7 +55,7 @@ namespace Orchard.Specs.Bindings {
[Given(@"I have a clean site based on (.*)")]
public void GivenIHaveACleanSiteBasedOn(string siteFolder) {
_webHost = new WebHost();
_webHost = new WebHost(_orchardTemp);
Host.Initialize(siteFolder, "/");
var shuttle = new Shuttle();
Host.Execute(() => {