1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

removed IEpisodeProvider, ILogProvider

fixed some broken tests.
This commit is contained in:
kay.one 2011-04-09 17:14:51 -07:00
parent 8fbc79c50d
commit 7efbfdbb89
19 changed files with 130 additions and 167 deletions

View File

@ -36,14 +36,23 @@ public virtual T Resolve<T>()
return result; return result;
} }
public virtual Mock<T> GetMock<T>() where T : class public virtual Mock<T> GetMock<T>(MockBehavior behavior = MockBehavior.Default) where T : class
{ {
ResolveType = null; ResolveType = null;
var type = GetTheMockType<T>(); var type = GetTheMockType<T>();
if (GetMockHasNotBeenCalledForThisType(type)) if (GetMockHasNotBeenCalledForThisType(type))
CreateANewMockAndRegisterIt<T>(type); {
CreateANewMockAndRegisterIt<T>(type, behavior);
}
return TheRegisteredMockForThisType<T>(type); var mock = TheRegisteredMockForThisType<T>(type);
if (behavior != MockBehavior.Default && mock.Behavior == MockBehavior.Default)
{
throw new InvalidOperationException("Unable to change be behaviour of a an existing mock.");
}
return mock;
} }
internal virtual void SetMock(Type type, Mock mock) internal virtual void SetMock(Type type, Mock mock)
@ -80,9 +89,9 @@ private Mock<T> TheRegisteredMockForThisType<T>(Type type) where T : class
return (Mock<T>)registeredMocks.Where(x => x.Key == type).First().Value; return (Mock<T>)registeredMocks.Where(x => x.Key == type).First().Value;
} }
private void CreateANewMockAndRegisterIt<T>(Type type) where T : class private void CreateANewMockAndRegisterIt<T>(Type type, MockBehavior behavior) where T : class
{ {
var mock = new Mock<T>(); var mock = new Mock<T>(behavior);
container.RegisterInstance(mock.Object); container.RegisterInstance(mock.Object);
SetMock(type, mock); SetMock(type, mock);
} }
@ -129,5 +138,14 @@ public void Verify<T>(Expression<Action<T>> expression, Times times, string fail
GetMock<T>().Verify(expression, times, failMessage); GetMock<T>().Verify(expression, times, failMessage);
} }
public void VerifyAllMocks()
{
foreach (var registeredMock in registeredMocks)
{
var mock = registeredMock.Value as Mock;
mock.VerifyAll();
}
}
} }
} }

View File

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Text; using System.Text;
using AutoMoq;
using FizzWare.NBuilder; using FizzWare.NBuilder;
using Gallio.Framework; using Gallio.Framework;
using MbUnit.Framework; using MbUnit.Framework;
@ -41,32 +42,29 @@ public void import_new_file()
var fakeEpisode = Builder<Episode>.CreateNew().With(c => c.SeriesId = fakeSeries.SeriesId).Build(); var fakeEpisode = Builder<Episode>.CreateNew().With(c => c.SeriesId = fakeSeries.SeriesId).Build();
//Mocks //Mocks
var repository = new Mock<IRepository>(); var mocker = new AutoMoqer();
repository.Setup(r => r.Exists<EpisodeFile>(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(false).Verifiable();
repository.Setup(r => r.Add(It.IsAny<EpisodeFile>())).Returns(0).Verifiable();
var episodeProvider = new Mock<IEpisodeProvider>(); mocker.GetMock<IRepository>()
episodeProvider.Setup(e => e.GetEpisode(fakeSeries.SeriesId, seasonNumber, episodeNumner)).Returns(fakeEpisode).Verifiable(); .Setup(r => r.Exists<EpisodeFile>(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(false).Verifiable();
mocker.GetMock<IRepository>()
.Setup(r => r.Add(It.IsAny<EpisodeFile>())).Returns(0).Verifiable();
var diskProvider = new Mock<DiskProvider>(); mocker.GetMock<EpisodeProvider>()
diskProvider.Setup(e => e.GetSize(fileName)).Returns(12345).Verifiable(); .Setup(e => e.GetEpisode(fakeSeries.SeriesId, seasonNumber, episodeNumner)).Returns(fakeEpisode).Verifiable();
var kernel = new MockingKernel(); mocker.GetMock<DiskProvider>()
kernel.Bind<IRepository>().ToConstant(repository.Object); .Setup(e => e.GetSize(fileName)).Returns(12345).Verifiable();
kernel.Bind<IEpisodeProvider>().ToConstant(episodeProvider.Object);
kernel.Bind<DiskProvider>().ToConstant(diskProvider.Object);
kernel.Bind<IMediaFileProvider>().To<MediaFileProvider>();
//Act //Act
var result = kernel.Get<IMediaFileProvider>().ImportFile(fakeSeries, fileName); var result = mocker.Resolve<MediaFileProvider>().ImportFile(fakeSeries, fileName);
//Assert //Assert
repository.VerifyAll();
episodeProvider.VerifyAll();
diskProvider.VerifyAll();
Assert.IsNotNull(result); Assert.IsNotNull(result);
repository.Verify(r => r.Add<EpisodeFile>(result), Times.Once()); mocker.GetMock<IRepository>().VerifyAll();
mocker.GetMock<IRepository>().Verify(r => r.Add<EpisodeFile>(result), Times.Once());
mocker.GetMock<EpisodeProvider>().VerifyAll();
mocker.GetMock<DiskProvider>().VerifyAll();
//Currently can't verify this since the list of episodes are loaded //Currently can't verify this since the list of episodes are loaded
//Dynamically by SubSonic //Dynamically by SubSonic
@ -93,31 +91,25 @@ public void import_existing_file()
//Fakes //Fakes
var fakeSeries = Builder<Series>.CreateNew().Build(); var fakeSeries = Builder<Series>.CreateNew().Build();
var fakeEpisode = Builder<Episode>.CreateNew().With(c => c.SeriesId = fakeSeries.SeriesId).Build();
//Mocks //Mocks
var repository = new Mock<IRepository>(MockBehavior.Strict);
repository.Setup(r => r.Exists<EpisodeFile>(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(true).Verifiable();
var episodeProvider = new Mock<IEpisodeProvider>(MockBehavior.Strict); var mocker = new AutoMoqer();
var diskProvider = new Mock<DiskProvider>(MockBehavior.Strict); mocker.GetMock<IRepository>(MockBehavior.Strict)
.Setup(r => r.Exists<EpisodeFile>(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(true).Verifiable();
mocker.GetMock<EpisodeProvider>(MockBehavior.Strict);
mocker.GetMock<DiskProvider>(MockBehavior.Strict);
var kernel = new MockingKernel();
kernel.Bind<IRepository>().ToConstant(repository.Object);
kernel.Bind<IEpisodeProvider>().ToConstant(episodeProvider.Object);
kernel.Bind<DiskProvider>().ToConstant(diskProvider.Object);
kernel.Bind<IMediaFileProvider>().To<MediaFileProvider>();
//Act //Act
var result = kernel.Get<IMediaFileProvider>().ImportFile(fakeSeries, fileName); var result = mocker.Resolve<MediaFileProvider>().ImportFile(fakeSeries, fileName);
//Assert //Assert
repository.VerifyAll(); mocker.GetMock<IRepository>().VerifyAll();
episodeProvider.VerifyAll(); mocker.GetMock<EpisodeProvider>().VerifyAll();
diskProvider.VerifyAll(); mocker.GetMock<DiskProvider>(MockBehavior.Strict).VerifyAll();
Assert.IsNull(result); Assert.IsNull(result);
repository.Verify(r => r.Add<EpisodeFile>(result), Times.Never()); mocker.GetMock<IRepository>().Verify(r => r.Add<EpisodeFile>(result), Times.Never());
} }
[Test] [Test]
@ -136,30 +128,23 @@ public void import_file_with_no_episode()
var fakeSeries = Builder<Series>.CreateNew().Build(); var fakeSeries = Builder<Series>.CreateNew().Build();
//Mocks //Mocks
var repository = new Mock<IRepository>(MockBehavior.Strict); var mocker = new AutoMoqer();
repository.Setup(r => r.Exists<EpisodeFile>(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(false).Verifiable(); mocker.GetMock<IRepository>(MockBehavior.Strict)
.Setup(r => r.Exists<EpisodeFile>(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(false).Verifiable();
var episodeProvider = new Mock<IEpisodeProvider>(MockBehavior.Strict); mocker.GetMock<EpisodeProvider>(MockBehavior.Strict)
episodeProvider.Setup(e => e.GetEpisode(fakeSeries.SeriesId, seasonNumber, episodeNumner)).Returns<Episode>(null).Verifiable(); .Setup(e => e.GetEpisode(fakeSeries.SeriesId, seasonNumber, episodeNumner)).Returns<Episode>(null).Verifiable();
var diskProvider = new Mock<DiskProvider>(MockBehavior.Strict); mocker.GetMock<DiskProvider>(MockBehavior.Strict);
var kernel = new MockingKernel();
kernel.Bind<IRepository>().ToConstant(repository.Object);
kernel.Bind<IEpisodeProvider>().ToConstant(episodeProvider.Object);
kernel.Bind<DiskProvider>().ToConstant(diskProvider.Object);
kernel.Bind<IMediaFileProvider>().To<MediaFileProvider>();
//Act //Act
var result = kernel.Get<IMediaFileProvider>().ImportFile(fakeSeries, fileName); var result = mocker.Resolve<MediaFileProvider>().ImportFile(fakeSeries, fileName);
//Assert //Assert
repository.VerifyAll(); mocker.VerifyAllMocks();
episodeProvider.VerifyAll();
diskProvider.VerifyAll();
Assert.IsNull(result); Assert.IsNull(result);
repository.Verify(r => r.Add<EpisodeFile>(result), Times.Never()); mocker.GetMock<IRepository>().Verify(r => r.Add<EpisodeFile>(result), Times.Never());
} }

View File

@ -43,7 +43,7 @@ public void Download_feed_test()
public class MockFeedProvider : FeedProviderBase public class MockFeedProvider : FeedProviderBase
{ {
public MockFeedProvider(SeriesProvider seriesProvider, ISeasonProvider seasonProvider, IEpisodeProvider episodeProvider, IConfigProvider configProvider, HttpProvider httpProvider) public MockFeedProvider(SeriesProvider seriesProvider, ISeasonProvider seasonProvider, EpisodeProvider episodeProvider, IConfigProvider configProvider, HttpProvider httpProvider)
: base(seriesProvider, seasonProvider, episodeProvider, configProvider, httpProvider) : base(seriesProvider, seasonProvider, episodeProvider, configProvider, httpProvider)
{ {
} }

View File

@ -24,13 +24,13 @@ namespace NzbDrone.Core
public static class CentralDispatch public static class CentralDispatch
{ {
private static StandardKernel _kernel; private static StandardKernel _kernel;
private static readonly Object kernelLock = new object(); private static readonly Object KernelLock = new object();
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private static string _startupPath; private static string _startupPath;
public static void BindKernel() public static void BindKernel()
{ {
lock (kernelLock) lock (KernelLock)
{ {
Logger.Debug("Binding Ninject's Kernel"); Logger.Debug("Binding Ninject's Kernel");
_kernel = new StandardKernel(); _kernel = new StandardKernel();
@ -57,27 +57,27 @@ public static void BindKernel()
dbProvider.Log = new NlogWriter(); dbProvider.Log = new NlogWriter();
_kernel.Bind<QualityProvider>().ToSelf(); _kernel.Bind<QualityProvider>().ToSelf().InSingletonScope();
_kernel.Bind<TvDbProvider>().ToSelf(); _kernel.Bind<TvDbProvider>().ToSelf().InSingletonScope();
_kernel.Bind<HttpProvider>().ToSelf(); _kernel.Bind<HttpProvider>().ToSelf().InSingletonScope();
_kernel.Bind<SeriesProvider>().ToSelf().InSingletonScope(); _kernel.Bind<SeriesProvider>().ToSelf().InSingletonScope();
_kernel.Bind<ISeasonProvider>().To<SeasonProvider>().InSingletonScope();
_kernel.Bind<RssSyncProvider>().ToSelf().InSingletonScope(); _kernel.Bind<RssSyncProvider>().ToSelf().InSingletonScope();
_kernel.Bind<ISeasonProvider>().To<SeasonProvider>(); _kernel.Bind<EpisodeProvider>().ToSelf().InSingletonScope();
_kernel.Bind<IEpisodeProvider>().To<EpisodeProvider>(); _kernel.Bind<UpcomingEpisodesProvider>().ToSelf().InSingletonScope();
_kernel.Bind<UpcomingEpisodesProvider>().ToSelf(); _kernel.Bind<DiskProvider>().ToSelf().InSingletonScope();
_kernel.Bind<DiskProvider>().ToSelf(); _kernel.Bind<SabProvider>().ToSelf().InSingletonScope();
_kernel.Bind<SabProvider>().ToSelf(); _kernel.Bind<HistoryProvider>().ToSelf().InSingletonScope();
_kernel.Bind<HistoryProvider>().ToSelf(); _kernel.Bind<RootDirProvider>().ToSelf().InSingletonScope();
_kernel.Bind<RootDirProvider>().ToSelf(); _kernel.Bind<ExternalNotificationProvider>().ToSelf().InSingletonScope();
_kernel.Bind<ExternalNotificationProvider>().ToSelf(); _kernel.Bind<XbmcProvider>().ToSelf().InSingletonScope();
_kernel.Bind<XbmcProvider>().ToSelf(); _kernel.Bind<PostProcessingProvider>().ToSelf().InSingletonScope();
_kernel.Bind<PostProcessingProvider>().ToSelf();
_kernel.Bind<IConfigProvider>().To<ConfigProvider>().InSingletonScope(); _kernel.Bind<IConfigProvider>().To<ConfigProvider>().InSingletonScope();
_kernel.Bind<ISyncProvider>().To<SyncProvider>().InSingletonScope(); _kernel.Bind<ISyncProvider>().To<SyncProvider>().InSingletonScope();
_kernel.Bind<IndexerProvider>().ToSelf().InSingletonScope(); _kernel.Bind<IndexerProvider>().ToSelf().InSingletonScope();
_kernel.Bind<RenameProvider>().ToSelf().InSingletonScope(); _kernel.Bind<RenameProvider>().ToSelf().InSingletonScope();
_kernel.Bind<NotificationProvider>().ToSelf().InSingletonScope(); _kernel.Bind<NotificationProvider>().ToSelf().InSingletonScope();
_kernel.Bind<ILogProvider>().To<LogProvider>().InSingletonScope(); _kernel.Bind<LogProvider>().ToSelf().InSingletonScope();
_kernel.Bind<IMediaFileProvider>().To<MediaFileProvider>().InSingletonScope(); _kernel.Bind<IMediaFileProvider>().To<MediaFileProvider>().InSingletonScope();
_kernel.Bind<TimerProvider>().ToSelf().InSingletonScope(); _kernel.Bind<TimerProvider>().ToSelf().InSingletonScope();
_kernel.Bind<IRepository>().ToMethod(c => new SimpleRepository(dbProvider, SimpleRepositoryOptions.RunMigrations)).InSingletonScope(); _kernel.Bind<IRepository>().ToMethod(c => new SimpleRepository(dbProvider, SimpleRepositoryOptions.RunMigrations)).InSingletonScope();

View File

@ -1,11 +0,0 @@
using System.Collections.Generic;
using System.Linq;
namespace NzbDrone.Core.Instrumentation
{
public interface ILogProvider
{
IQueryable<Log> GetAllLogs();
void DeleteAll();
}
}

View File

@ -8,7 +8,7 @@
namespace NzbDrone.Core.Instrumentation namespace NzbDrone.Core.Instrumentation
{ {
public class LogProvider : ILogProvider public class LogProvider
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly IRepository _repository; private readonly IRepository _repository;

View File

@ -163,7 +163,6 @@
<Compile Include="Helpers\EpisodeSortingHelper.cs" /> <Compile Include="Helpers\EpisodeSortingHelper.cs" />
<Compile Include="Helpers\SceneNameHelper.cs" /> <Compile Include="Helpers\SceneNameHelper.cs" />
<Compile Include="Helpers\ServerHelper.cs" /> <Compile Include="Helpers\ServerHelper.cs" />
<Compile Include="Instrumentation\ILogProvider.cs" />
<Compile Include="Instrumentation\LogLevel.cs" /> <Compile Include="Instrumentation\LogLevel.cs" />
<Compile Include="Instrumentation\LogProvider.cs" /> <Compile Include="Instrumentation\LogProvider.cs" />
<Compile Include="Instrumentation\SubsonicTarget.cs" /> <Compile Include="Instrumentation\SubsonicTarget.cs" />
@ -208,7 +207,6 @@
<Compile Include="Providers\Core\ConfigProvider.cs" /> <Compile Include="Providers\Core\ConfigProvider.cs" />
<Compile Include="Providers\EpisodeProvider.cs" /> <Compile Include="Providers\EpisodeProvider.cs" />
<Compile Include="Providers\Core\HttpProvider.cs" /> <Compile Include="Providers\Core\HttpProvider.cs" />
<Compile Include="Providers\IEpisodeProvider.cs" />
<Compile Include="Providers\ISeasonProvider.cs" /> <Compile Include="Providers\ISeasonProvider.cs" />
<Compile Include="Providers\SabProvider.cs" /> <Compile Include="Providers\SabProvider.cs" />
<Compile Include="Providers\SeasonProvider.cs" /> <Compile Include="Providers\SeasonProvider.cs" />

View File

@ -9,7 +9,7 @@
namespace NzbDrone.Core.Providers namespace NzbDrone.Core.Providers
{ {
public class EpisodeProvider : IEpisodeProvider public class EpisodeProvider
{ {
//TODO: Remove parsing of the series name, it should be done in series provider //TODO: Remove parsing of the series name, it should be done in series provider
@ -33,27 +33,32 @@ public EpisodeProvider(IRepository sonicRepo, SeriesProvider seriesProvider,
_quality = quality; _quality = quality;
} }
public Episode GetEpisode(long id) public EpisodeProvider()
{
}
public virtual Episode GetEpisode(long id)
{ {
return _sonicRepo.Single<Episode>(id); return _sonicRepo.Single<Episode>(id);
} }
public Episode GetEpisode(int seriesId, int seasonNumber, int episodeNumber) public virtual Episode GetEpisode(int seriesId, int seasonNumber, int episodeNumber)
{ {
return _sonicRepo.Single<Episode>(c => c.SeriesId == seriesId && c.SeasonNumber == seasonNumber && c.EpisodeNumber == episodeNumber); return _sonicRepo.Single<Episode>(c => c.SeriesId == seriesId && c.SeasonNumber == seasonNumber && c.EpisodeNumber == episodeNumber);
} }
public IList<Episode> GetEpisodeBySeries(long seriesId) public virtual IList<Episode> GetEpisodeBySeries(long seriesId)
{ {
return _sonicRepo.Find<Episode>(e => e.SeriesId == seriesId); return _sonicRepo.Find<Episode>(e => e.SeriesId == seriesId);
} }
public IList<Episode> GetEpisodeBySeason(long seasonId) public virtual IList<Episode> GetEpisodeBySeason(long seasonId)
{ {
return _sonicRepo.Find<Episode>(e => e.SeasonId == seasonId); return _sonicRepo.Find<Episode>(e => e.SeasonId == seasonId);
} }
public String GetSabTitle(Episode episode) public virtual String GetSabTitle(Episode episode)
{ {
var series = _series.GetSeries(episode.SeriesId); var series = _series.GetSeries(episode.SeriesId);
if (series == null) throw new ArgumentException("Unknown series. ID: " + episode.SeriesId); if (series == null) throw new ArgumentException("Unknown series. ID: " + episode.SeriesId);
@ -67,7 +72,7 @@ public String GetSabTitle(Episode episode)
/// </summary> /// </summary>
/// <param name="parsedReport">Episode that needs to be checked</param> /// <param name="parsedReport">Episode that needs to be checked</param>
/// <returns></returns> /// <returns></returns>
public bool IsNeeded(EpisodeParseResult parsedReport) public virtual bool IsNeeded(EpisodeParseResult parsedReport)
{ {
foreach (var episode in parsedReport.Episodes) foreach (var episode in parsedReport.Episodes)
{ {
@ -114,7 +119,7 @@ public bool IsNeeded(EpisodeParseResult parsedReport)
} }
public void RefreshEpisodeInfo(int seriesId) public virtual void RefreshEpisodeInfo(int seriesId)
{ {
Logger.Info("Starting episode info refresh for series:{0}", seriesId); Logger.Info("Starting episode info refresh for series:{0}", seriesId);
int successCount = 0; int successCount = 0;
@ -178,7 +183,7 @@ public void RefreshEpisodeInfo(int seriesId)
Logger.Debug("Finished episode refresh for series:{0}. Successful:{1} - Failed:{2} ", targetSeries.SeriesName, successCount, failCount); Logger.Debug("Finished episode refresh for series:{0}. Successful:{1} - Failed:{2} ", targetSeries.SeriesName, successCount, failCount);
} }
public void RefreshEpisodeInfo(Season season) public virtual void RefreshEpisodeInfo(Season season)
{ {
Logger.Info("Starting episode info refresh for season {0} of series:{1}", season.SeasonNumber, season.SeriesId); Logger.Info("Starting episode info refresh for season {0} of series:{1}", season.SeasonNumber, season.SeriesId);
int successCount = 0; int successCount = 0;
@ -237,27 +242,15 @@ public void RefreshEpisodeInfo(Season season)
Logger.Debug("Finished episode refresh for series:{0}. Successful:{1} - Failed:{2} ", targetSeries.SeriesName, successCount, failCount); Logger.Debug("Finished episode refresh for series:{0}. Successful:{1} - Failed:{2} ", targetSeries.SeriesName, successCount, failCount);
} }
public void DeleteEpisode(int episodeId) public virtual void DeleteEpisode(int episodeId)
{ {
_sonicRepo.Delete<Episode>(episodeId); _sonicRepo.Delete<Episode>(episodeId);
} }
public void UpdateEpisode(Episode episode) public virtual void UpdateEpisode(Episode episode)
{ {
_sonicRepo.Update(episode); _sonicRepo.Update(episode);
} }
private bool IsSeasonIgnored(EpisodeParseResult episode)
{
//Check if this Season is ignored
if (_seasons.IsIgnored(episode.SeriesId, episode.SeasonNumber))
{
Logger.Debug("Season {0} is ignored for: {1}", episode.SeasonNumber, episode.SeriesTitle);
return true;
}
Logger.Debug("Season {0} is wanted for: {1}", episode.SeasonNumber, episode.SeriesTitle);
return false;
}
} }
} }

View File

@ -10,13 +10,13 @@ public abstract class FeedProviderBase
{ {
protected readonly SeriesProvider _seriesProvider; protected readonly SeriesProvider _seriesProvider;
protected readonly ISeasonProvider _seasonProvider; protected readonly ISeasonProvider _seasonProvider;
protected readonly IEpisodeProvider _episodeProvider; protected readonly EpisodeProvider _episodeProvider;
protected readonly IConfigProvider _configProvider; protected readonly IConfigProvider _configProvider;
private readonly HttpProvider _httpProvider; private readonly HttpProvider _httpProvider;
protected static readonly Logger Logger = LogManager.GetCurrentClassLogger(); protected static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public FeedProviderBase(SeriesProvider seriesProvider, ISeasonProvider seasonProvider, public FeedProviderBase(SeriesProvider seriesProvider, ISeasonProvider seasonProvider,
IEpisodeProvider episodeProvider, IConfigProvider configProvider, HttpProvider httpProvider) EpisodeProvider episodeProvider, IConfigProvider configProvider, HttpProvider httpProvider)
{ {
_seriesProvider = seriesProvider; _seriesProvider = seriesProvider;
_seasonProvider = seasonProvider; _seasonProvider = seasonProvider;

View File

@ -9,7 +9,7 @@ namespace NzbDrone.Core.Providers.Feed
{ {
class NzbsOrgFeedProvider : FeedProviderBase class NzbsOrgFeedProvider : FeedProviderBase
{ {
public NzbsOrgFeedProvider(SeriesProvider seriesProvider, ISeasonProvider seasonProvider, IEpisodeProvider episodeProvider, IConfigProvider configProvider, HttpProvider httpProvider) public NzbsOrgFeedProvider(SeriesProvider seriesProvider, ISeasonProvider seasonProvider, EpisodeProvider episodeProvider, IConfigProvider configProvider, HttpProvider httpProvider)
: base(seriesProvider, seasonProvider, episodeProvider, configProvider, httpProvider) : base(seriesProvider, seasonProvider, episodeProvider, configProvider, httpProvider)
{ {
} }

View File

@ -20,6 +20,10 @@ public HistoryProvider(IRepository sonicRepo)
_sonicRepo = sonicRepo; _sonicRepo = sonicRepo;
} }
public HistoryProvider()
{
}
#region HistoryProvider Members #region HistoryProvider Members
public virtual List<History> AllItems() public virtual List<History> AllItems()

View File

@ -1,28 +0,0 @@
using System;
using System.Collections.Generic;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Providers
{
public interface IEpisodeProvider
{
Episode GetEpisode(long id);
Episode GetEpisode(int seriesId, int seasonNumber, int episodeNumber);
IList<Episode> GetEpisodeBySeries(long seriesId);
String GetSabTitle(Episode episode);
/// <summary>
/// Comprehensive check on whether or not this episode is needed.
/// </summary>
/// <param name="episode">Episode that needs to be checked</param>
/// <returns></returns>
bool IsNeeded(EpisodeParseResult episode);
void RefreshEpisodeInfo(int seriesId);
void RefreshEpisodeInfo(Season season);
IList<Episode> GetEpisodeBySeason(long seasonId);
void DeleteEpisode(int episodeId);
void UpdateEpisode(Episode episode);
}
}

View File

@ -17,12 +17,12 @@ public class MediaFileProvider : IMediaFileProvider
private readonly IRepository _repository; private readonly IRepository _repository;
private readonly IConfigProvider _configProvider; private readonly IConfigProvider _configProvider;
private readonly DiskProvider _diskProvider; private readonly DiskProvider _diskProvider;
private readonly IEpisodeProvider _episodeProvider; private readonly EpisodeProvider _episodeProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private static readonly string[] MediaExtentions = new[] { "*.mkv", "*.avi", "*.wmv" }; private static readonly string[] MediaExtentions = new[] { "*.mkv", "*.avi", "*.wmv" };
public MediaFileProvider(IRepository repository, IConfigProvider configProvider, DiskProvider diskProvider, IEpisodeProvider episodeProvider) public MediaFileProvider(IRepository repository, IConfigProvider configProvider, DiskProvider diskProvider, EpisodeProvider episodeProvider)
{ {
_repository = repository; _repository = repository;
_configProvider = configProvider; _configProvider = configProvider;

View File

@ -16,7 +16,7 @@ public class RenameProvider
{ {
private readonly SeriesProvider _seriesProvider; private readonly SeriesProvider _seriesProvider;
private readonly ISeasonProvider _seasonProvider; private readonly ISeasonProvider _seasonProvider;
private readonly IEpisodeProvider _episodeProvider; private readonly EpisodeProvider _episodeProvider;
private readonly IMediaFileProvider _mediaFileProvider; private readonly IMediaFileProvider _mediaFileProvider;
private readonly DiskProvider _diskProvider; private readonly DiskProvider _diskProvider;
private readonly IConfigProvider _configProvider; private readonly IConfigProvider _configProvider;
@ -28,7 +28,7 @@ public class RenameProvider
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public RenameProvider(SeriesProvider seriesProvider, ISeasonProvider seasonProvider, public RenameProvider(SeriesProvider seriesProvider, ISeasonProvider seasonProvider,
IEpisodeProvider episodeProvider, IMediaFileProvider mediaFileProvider, EpisodeProvider episodeProvider, IMediaFileProvider mediaFileProvider,
DiskProvider diskProvider, IConfigProvider configProvider, DiskProvider diskProvider, IConfigProvider configProvider,
ExternalNotificationProvider extenalNotificationProvider) ExternalNotificationProvider extenalNotificationProvider)
{ {

View File

@ -34,6 +34,10 @@ public SeriesProvider(IConfigProvider configProvider,
_quality = quality; _quality = quality;
} }
public SeriesProvider()
{
}
#region SeriesProvider Members #region SeriesProvider Members
public virtual IQueryable<Series> GetAllSeries() public virtual IQueryable<Series> GetAllSeries()

View File

@ -14,7 +14,7 @@ namespace NzbDrone.Core.Providers
public class SyncProvider : ISyncProvider public class SyncProvider : ISyncProvider
{ {
private readonly SeriesProvider _seriesProvider; private readonly SeriesProvider _seriesProvider;
private readonly IEpisodeProvider _episodeProvider; private readonly EpisodeProvider _episodeProvider;
private readonly IMediaFileProvider _mediaFileProvider; private readonly IMediaFileProvider _mediaFileProvider;
private readonly NotificationProvider _notificationProvider; private readonly NotificationProvider _notificationProvider;
private readonly DiskProvider _diskProvider; private readonly DiskProvider _diskProvider;
@ -24,7 +24,7 @@ public class SyncProvider : ISyncProvider
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public SyncProvider(SeriesProvider seriesProvider, IEpisodeProvider episodeProvider, public SyncProvider(SeriesProvider seriesProvider, EpisodeProvider episodeProvider,
IMediaFileProvider mediaFileProvider, NotificationProvider notificationProvider, IMediaFileProvider mediaFileProvider, NotificationProvider notificationProvider,
DiskProvider diskProvider) DiskProvider diskProvider)
{ {

View File

@ -13,7 +13,7 @@ public class TimerProvider
private readonly RssSyncProvider _rssSyncProvider; private readonly RssSyncProvider _rssSyncProvider;
private readonly SeriesProvider _seriesProvider; private readonly SeriesProvider _seriesProvider;
private readonly ISeasonProvider _seasonProvider; private readonly ISeasonProvider _seasonProvider;
private readonly IEpisodeProvider _episodeProvider; private readonly EpisodeProvider _episodeProvider;
private readonly IMediaFileProvider _mediaFileProvider; private readonly IMediaFileProvider _mediaFileProvider;
private Timer _rssSyncTimer; private Timer _rssSyncTimer;
@ -21,7 +21,7 @@ public class TimerProvider
private DateTime _rssSyncNextInterval; private DateTime _rssSyncNextInterval;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public TimerProvider(RssSyncProvider rssSyncProvider, SeriesProvider seriesProvider, ISeasonProvider seasonProvider, IEpisodeProvider episodeProvider, IMediaFileProvider mediaFileProvider) public TimerProvider(RssSyncProvider rssSyncProvider, SeriesProvider seriesProvider, ISeasonProvider seasonProvider, EpisodeProvider episodeProvider, IMediaFileProvider mediaFileProvider)
{ {
_rssSyncProvider = rssSyncProvider; _rssSyncProvider = rssSyncProvider;
_seriesProvider = seriesProvider; _seriesProvider = seriesProvider;

View File

@ -11,9 +11,9 @@ namespace NzbDrone.Web.Controllers
{ {
public class LogController : Controller public class LogController : Controller
{ {
private readonly ILogProvider _logProvider; private readonly LogProvider _logProvider;
public LogController(ILogProvider logProvider) public LogController(LogProvider logProvider)
{ {
_logProvider = logProvider; _logProvider = logProvider;
} }

View File

@ -22,7 +22,7 @@ namespace NzbDrone.Web.Controllers
public class SeriesController : Controller public class SeriesController : Controller
{ {
private readonly SeriesProvider _seriesProvider; private readonly SeriesProvider _seriesProvider;
private readonly IEpisodeProvider _episodeProvider; private readonly EpisodeProvider _episodeProvider;
private readonly ISyncProvider _syncProvider; private readonly ISyncProvider _syncProvider;
private readonly RssSyncProvider _rssSyncProvider; private readonly RssSyncProvider _rssSyncProvider;
private readonly QualityProvider _qualityProvider; private readonly QualityProvider _qualityProvider;
@ -34,7 +34,7 @@ public class SeriesController : Controller
// GET: /Series/ // GET: /Series/
public SeriesController(ISyncProvider syncProvider, SeriesProvider seriesProvider, public SeriesController(ISyncProvider syncProvider, SeriesProvider seriesProvider,
IEpisodeProvider episodeProvider, RssSyncProvider rssSyncProvider, EpisodeProvider episodeProvider, RssSyncProvider rssSyncProvider,
QualityProvider qualityProvider, IMediaFileProvider mediaFileProvider, QualityProvider qualityProvider, IMediaFileProvider mediaFileProvider,
RenameProvider renameProvider, RootDirProvider rootDirProvider, RenameProvider renameProvider, RootDirProvider rootDirProvider,
TvDbProvider tvDbProvider) TvDbProvider tvDbProvider)