1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-14 11:23:42 +02:00
Sonarr/NzbDrone.Core.Test/Framework/ObjectDbTest.cs

46 lines
1.1 KiB
C#
Raw Normal View History

2013-02-04 03:10:15 +03:00
using System;
using System.Linq;
using NUnit.Framework;
2013-02-04 07:18:59 +03:00
using NzbDrone.Common;
2013-02-04 03:10:15 +03:00
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)
{
2013-02-04 07:18:59 +03:00
_db = new EloqueraDbFactory(new EnvironmentProvider()).CreateMemoryDb();
2013-02-04 03:10:15 +03:00
}
else
{
2013-02-04 07:18:59 +03:00
_db = new EloqueraDbFactory(new EnvironmentProvider()).Create();
2013-02-04 03:10:15 +03:00
}
Mocker.SetConstant(Db);
}
[TearDown]
public void ObjectDbTearDown()
{
if (_db != null)
{
_db.Dispose();
}
}
}
}