mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-14 17:13:49 -07:00
updated eloquera's test setup.
This commit is contained in:
parent
23b90ae1c4
commit
d13f977bb5
8 changed files with 92 additions and 147 deletions
45
NzbDrone.Core.Test/Framework/ObjectDbTest.cs
Normal file
45
NzbDrone.Core.Test/Framework/ObjectDbTest.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue