separated sqlce and db4o tests.

This commit is contained in:
kay.one
2013-02-02 12:54:03 -08:00
parent 9f829c1442
commit f973a42669
106 changed files with 192 additions and 176 deletions
@@ -1,6 +1,6 @@
namespace NzbDrone.Core.Test.Framework
{
public abstract class CoreTest<TSubject> : CoreTest where TSubject : class
public abstract class SqlCeTest<TSubject> : SqlCeTest where TSubject : class
{
private TSubject _subject;
@@ -10,7 +10,66 @@ using PetaPoco;
namespace NzbDrone.Core.Test.Framework
{
public abstract class CoreTest : TestBase
{
protected static ProgressNotification MockNotification
{
get
{
return new ProgressNotification("Mock notification");
}
}
protected static void ThrowException()
{
throw new ApplicationException("This is a message for test exception");
}
}
public abstract class ObjectDbTest : CoreTest
{
private IObjectDbSession _db;
protected IObjectDbSession Db
{
get
{
if (_db == null)
throw new InvalidOperationException("Test object database doesn't exists. Make sure you call WithRealDb() if you intend to use an actual database.");
return _db;
}
}
protected void WithObjectDb(bool memory = true)
{
if (memory)
{
_db = new ObjectDbSessionFactory().Create(new PagingMemoryStorage());
}
else
{
_db = new ObjectDbSessionFactory().Create(dbName: Guid.NewGuid().ToString());
}
Mocker.SetConstant(Db);
}
[TearDown]
public void ObjectDbTearDown()
{
if (_db != null)
{
_db.Dispose();
}
}
}
public abstract class SqlCeTest : CoreTest
{
private string _dbTemplateName;
@@ -73,18 +132,6 @@ namespace NzbDrone.Core.Test.Framework
}
}
private IObjectDbSession _objDb;
protected IObjectDbSession ObjDb
{
get
{
if (_objDb == null)
throw new InvalidOperationException("Test object database doesn't exists. Make sure you call WithRealDb() if you intend to use an actual database.");
return _objDb;
}
}
protected void WithRealDb()
@@ -93,32 +140,6 @@ namespace NzbDrone.Core.Test.Framework
Mocker.SetConstant(Db);
}
protected void WithObjectDb(bool memory = true)
{
if (memory)
{
_objDb = new ObjectDbSessionFactory().Create(new PagingMemoryStorage());
}
else
{
_objDb = new ObjectDbSessionFactory().Create(dbName: Guid.NewGuid().ToString());
}
Mocker.SetConstant(ObjDb);
}
protected static ProgressNotification MockNotification
{
get
{
return new ProgressNotification("Mock notification");
}
}
protected static void ThrowException()
{
throw new ApplicationException("This is a message for test exception");
}
[TearDown]
public void CoreTestTearDown()
@@ -136,11 +157,6 @@ namespace NzbDrone.Core.Test.Framework
}
catch (IOException) { }
}
if (_objDb != null)
{
_objDb.Dispose();
}
}
}
}