2011-11-13 07:27:16 +00:00
|
|
|
|
using System.IO;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using Ninject;
|
2011-11-14 00:22:18 +00:00
|
|
|
|
using NzbDrone.Common;
|
2011-11-18 04:36:37 +00:00
|
|
|
|
using NzbDrone.Core.Model.Notification;
|
2011-11-13 07:27:16 +00:00
|
|
|
|
using NzbDrone.Test.Common;
|
|
|
|
|
using PetaPoco;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.Framework
|
|
|
|
|
{
|
|
|
|
|
public class CoreTest : TestBase
|
|
|
|
|
// ReSharper disable InconsistentNaming
|
|
|
|
|
{
|
|
|
|
|
static CoreTest()
|
|
|
|
|
{
|
2011-11-14 00:22:18 +00:00
|
|
|
|
//Delete old db files
|
2011-11-13 07:27:16 +00:00
|
|
|
|
var oldDbFiles = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.sdf", SearchOption.AllDirectories);
|
|
|
|
|
foreach (var file in oldDbFiles)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
File.Delete(file);
|
|
|
|
|
}
|
|
|
|
|
catch { }
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-14 00:22:18 +00:00
|
|
|
|
//Delete App_data folder
|
|
|
|
|
var appData = new EnviromentProvider().GetAppDataPath();
|
|
|
|
|
|
|
|
|
|
if (Directory.Exists(appData))
|
|
|
|
|
{
|
|
|
|
|
Directory.Delete(appData, true);
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-23 05:58:26 +00:00
|
|
|
|
TestDbHelper.CreateDataBaseTemplate();
|
2011-11-13 07:27:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected StandardKernel LiveKernel = null;
|
|
|
|
|
protected IDatabase Db = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
2011-11-18 04:36:37 +00:00
|
|
|
|
public virtual void CoreTestSetup()
|
2011-11-13 07:27:16 +00:00
|
|
|
|
{
|
|
|
|
|
LiveKernel = new StandardKernel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void WithStrictMocker()
|
|
|
|
|
{
|
|
|
|
|
base.WithStrictMocker();
|
|
|
|
|
|
|
|
|
|
if (Db != null)
|
|
|
|
|
{
|
|
|
|
|
Mocker.SetConstant(Db);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void WithRealDb()
|
|
|
|
|
{
|
2011-11-23 05:58:26 +00:00
|
|
|
|
Db = TestDbHelper.GetEmptyDatabase();
|
2011-11-13 07:27:16 +00:00
|
|
|
|
Mocker.SetConstant(Db);
|
|
|
|
|
}
|
2011-11-18 04:36:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected ProgressNotification MockNotification
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return new ProgressNotification("Mock notification");
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-11-13 07:27:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|