2013-06-09 20:50:57 +00:00
|
|
|
|
using System.IO;
|
2013-02-05 04:07:07 +00:00
|
|
|
|
using NUnit.Framework;
|
2013-04-16 00:08:06 +00:00
|
|
|
|
using NzbDrone.Common;
|
2013-02-05 04:07:07 +00:00
|
|
|
|
using NzbDrone.Test.Common;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.Framework
|
|
|
|
|
{
|
|
|
|
|
public abstract class CoreTest : TestBase
|
|
|
|
|
{
|
2013-06-09 20:50:57 +00:00
|
|
|
|
|
2013-02-05 04:07:07 +00:00
|
|
|
|
|
2013-02-18 04:01:59 +00:00
|
|
|
|
protected FileStream OpenRead(params string[] path)
|
|
|
|
|
{
|
|
|
|
|
return File.OpenRead(Path.Combine(path));
|
|
|
|
|
}
|
2013-03-28 19:05:43 +00:00
|
|
|
|
|
|
|
|
|
protected string ReadAllText(params string[] path)
|
|
|
|
|
{
|
2013-03-28 19:18:08 +00:00
|
|
|
|
return File.ReadAllText(Path.Combine(path));
|
2013-03-28 19:05:43 +00:00
|
|
|
|
}
|
2013-04-16 00:08:06 +00:00
|
|
|
|
|
|
|
|
|
protected void UseRealHttp()
|
|
|
|
|
{
|
2013-06-28 00:04:52 +00:00
|
|
|
|
Mocker.SetConstant<IHttpProvider>(new HttpProvider());
|
2013-04-16 00:08:06 +00:00
|
|
|
|
}
|
2013-06-28 00:12:50 +00:00
|
|
|
|
|
|
|
|
|
protected void UseRealDisk()
|
|
|
|
|
{
|
|
|
|
|
Mocker.SetConstant<IDiskProvider>(new DiskProvider());
|
|
|
|
|
WithTempAsAppPath();
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-05 04:07:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-23 21:29:22 +00:00
|
|
|
|
public abstract class CoreTest<TSubject> : CoreTest where TSubject : class
|
2013-02-05 04:07:07 +00:00
|
|
|
|
{
|
2013-02-18 07:59:43 +00:00
|
|
|
|
private TSubject _subject;
|
|
|
|
|
|
2013-02-05 04:07:07 +00:00
|
|
|
|
[SetUp]
|
|
|
|
|
public void CoreTestSetup()
|
|
|
|
|
{
|
2013-02-18 07:59:43 +00:00
|
|
|
|
_subject = null;
|
2013-02-05 04:07:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-18 07:59:43 +00:00
|
|
|
|
protected TSubject Subject
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_subject == null)
|
|
|
|
|
{
|
|
|
|
|
_subject = Mocker.Resolve<TSubject>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _subject;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2013-02-05 04:07:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|