PathProvider. visit us for all of your pathing needs.

This commit is contained in:
kay.one 2011-11-02 22:04:14 -07:00
parent c503b497ed
commit 633f0b6197
24 changed files with 315 additions and 188 deletions

View file

@ -1,13 +1,47 @@
using System.IO;
using AutoMoq;
using NUnit.Framework;
using Ninject;
using NzbDrone.Common;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.Framework
{
public class TestBase
public class TestBase : LoggingTest
// ReSharper disable InconsistentNaming
{
static TestBase()
{
InitLogging();
var oldDbFiles = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.sdf", SearchOption.AllDirectories);
foreach (var file in oldDbFiles)
{
try
{
File.Delete(file);
}
catch { }
}
MockLib.CreateDataBaseTemplate();
}
protected StandardKernel LiveKernel = null;
protected AutoMoqer Mocker = null;
protected string VirtualPath
{
get
{
var virtualPath = Path.Combine(TempFolder, "VirtualNzbDrone");
if (!Directory.Exists(virtualPath)) Directory.CreateDirectory(virtualPath);
return virtualPath;
}
}
[SetUp]
public virtual void SetupBase()
{
@ -18,6 +52,9 @@ namespace NzbDrone.Core.Test.Framework
}
Directory.CreateDirectory(TempFolder);
LiveKernel = new StandardKernel();
Mocker = new AutoMoqer();
}
[TearDown]
@ -27,6 +64,16 @@ namespace NzbDrone.Core.Test.Framework
}
protected void WithTempAsStartUpPath()
{
Mocker.GetMock<EnviromentProvider>()
.SetupGet(c => c.ApplicationPath)
.Returns(VirtualPath);
Mocker.Resolve<PathProvider>();
}
protected string TempFolder
{
get { return Path.Combine(Directory.GetCurrentDirectory(), "temp"); }