2013-02-05 05:07:07 +01:00
|
|
|
|
using System;
|
2013-02-18 05:01:59 +01:00
|
|
|
|
using System.IO;
|
2013-02-05 05:07:07 +01:00
|
|
|
|
using NUnit.Framework;
|
2013-04-16 02:08:06 +02:00
|
|
|
|
using NzbDrone.Common;
|
2013-02-05 05:07:07 +01:00
|
|
|
|
using NzbDrone.Core.Model.Notification;
|
|
|
|
|
using NzbDrone.Test.Common;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.Framework
|
|
|
|
|
{
|
|
|
|
|
public abstract class CoreTest : TestBase
|
|
|
|
|
{
|
|
|
|
|
protected static ProgressNotification MockNotification
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return new ProgressNotification("Mock notification");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-18 05:01:59 +01:00
|
|
|
|
protected FileStream OpenRead(params string[] path)
|
|
|
|
|
{
|
|
|
|
|
return File.OpenRead(Path.Combine(path));
|
|
|
|
|
}
|
2013-03-28 20:05:43 +01:00
|
|
|
|
|
|
|
|
|
protected string ReadAllText(params string[] path)
|
|
|
|
|
{
|
2013-03-28 20:18:08 +01:00
|
|
|
|
return File.ReadAllText(Path.Combine(path));
|
2013-03-28 20:05:43 +01:00
|
|
|
|
}
|
2013-04-16 02:08:06 +02:00
|
|
|
|
|
|
|
|
|
protected void UseRealHttp()
|
|
|
|
|
{
|
|
|
|
|
Mocker.SetConstant<IHttpProvider>(new HttpProvider(new EnvironmentProvider()));
|
|
|
|
|
}
|
2013-02-05 05:07:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-23 22:29:22 +01:00
|
|
|
|
public abstract class CoreTest<TSubject> : CoreTest where TSubject : class
|
2013-02-05 05:07:07 +01:00
|
|
|
|
{
|
2013-02-18 08:59:43 +01:00
|
|
|
|
private TSubject _subject;
|
|
|
|
|
|
2013-02-05 05:07:07 +01:00
|
|
|
|
[SetUp]
|
|
|
|
|
public void CoreTestSetup()
|
|
|
|
|
{
|
2013-02-18 08:59:43 +01:00
|
|
|
|
_subject = null;
|
2013-02-05 05:07:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-18 08:59:43 +01:00
|
|
|
|
protected TSubject Subject
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_subject == null)
|
|
|
|
|
{
|
|
|
|
|
_subject = Mocker.Resolve<TSubject>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _subject;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2013-02-05 05:07:07 +01:00
|
|
|
|
}
|
|
|
|
|
}
|