You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
45 lines
1.1 KiB
using System;
|
|
using System.Linq;
|
|
using NUnit.Framework;
|
|
using NzbDrone.Core.Datastore;
|
|
|
|
namespace NzbDrone.Core.Test.Framework
|
|
{
|
|
public abstract class ObjectDbTest : CoreTest
|
|
{
|
|
private EloqueraDb _db;
|
|
protected EloqueraDb 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 EloqueraDbFactory().CreateMemoryDb();
|
|
}
|
|
else
|
|
{
|
|
_db = new EloqueraDbFactory().Create(Guid.NewGuid().ToString());
|
|
}
|
|
|
|
Mocker.SetConstant(Db);
|
|
}
|
|
|
|
[TearDown]
|
|
public void ObjectDbTearDown()
|
|
{
|
|
if (_db != null)
|
|
{
|
|
_db.Dispose();
|
|
}
|
|
}
|
|
}
|
|
} |