Removed IDiskProvider.

Removed IIndexerProvider.
This commit is contained in:
Mark McDowall 2011-04-08 17:21:57 -07:00
parent e5413d67d6
commit 1a9948de2f
12 changed files with 34 additions and 70 deletions

View File

@ -48,14 +48,14 @@ namespace NzbDrone.Core.Test
var episodeProvider = new Mock<IEpisodeProvider>();
episodeProvider.Setup(e => e.GetEpisode(fakeSeries.SeriesId, seasonNumber, episodeNumner)).Returns(fakeEpisode).Verifiable();
var diskProvider = new Mock<IDiskProvider>();
var diskProvider = new Mock<DiskProvider>();
diskProvider.Setup(e => e.GetSize(fileName)).Returns(12345).Verifiable();
var kernel = new MockingKernel();
kernel.Bind<IRepository>().ToConstant(repository.Object);
kernel.Bind<IEpisodeProvider>().ToConstant(episodeProvider.Object);
kernel.Bind<IDiskProvider>().ToConstant(diskProvider.Object);
kernel.Bind<DiskProvider>().ToConstant(diskProvider.Object);
kernel.Bind<IMediaFileProvider>().To<MediaFileProvider>();
//Act
@ -100,13 +100,13 @@ namespace NzbDrone.Core.Test
repository.Setup(r => r.Exists<EpisodeFile>(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(true).Verifiable();
var episodeProvider = new Mock<IEpisodeProvider>(MockBehavior.Strict);
var diskProvider = new Mock<IDiskProvider>(MockBehavior.Strict);
var diskProvider = new Mock<DiskProvider>(MockBehavior.Strict);
var kernel = new MockingKernel();
kernel.Bind<IRepository>().ToConstant(repository.Object);
kernel.Bind<IEpisodeProvider>().ToConstant(episodeProvider.Object);
kernel.Bind<IDiskProvider>().ToConstant(diskProvider.Object);
kernel.Bind<DiskProvider>().ToConstant(diskProvider.Object);
kernel.Bind<IMediaFileProvider>().To<MediaFileProvider>();
//Act
@ -142,13 +142,13 @@ namespace NzbDrone.Core.Test
var episodeProvider = new Mock<IEpisodeProvider>(MockBehavior.Strict);
episodeProvider.Setup(e => e.GetEpisode(fakeSeries.SeriesId, seasonNumber, episodeNumner)).Returns<Episode>(null).Verifiable();
var diskProvider = new Mock<IDiskProvider>(MockBehavior.Strict);
var diskProvider = new Mock<DiskProvider>(MockBehavior.Strict);
var kernel = new MockingKernel();
kernel.Bind<IRepository>().ToConstant(repository.Object);
kernel.Bind<IEpisodeProvider>().ToConstant(episodeProvider.Object);
kernel.Bind<IDiskProvider>().ToConstant(diskProvider.Object);
kernel.Bind<DiskProvider>().ToConstant(diskProvider.Object);
kernel.Bind<IMediaFileProvider>().To<MediaFileProvider>();
//Act

View File

@ -52,9 +52,9 @@ namespace NzbDrone.Core.Test
}
}
public static IDiskProvider GetStandardDisk(int seasons, int episodes)
public static DiskProvider GetStandardDisk(int seasons, int episodes)
{
var mock = new Mock<IDiskProvider>();
var mock = new Mock<DiskProvider>();
mock.Setup(c => c.GetDirectories(It.IsAny<String>())).Returns(StandardSeries);
mock.Setup(c => c.FolderExists(It.Is<String>(d => StandardSeries.Contains(d)))).Returns(true);

View File

@ -64,8 +64,8 @@ namespace NzbDrone.Core
_kernel.Bind<RssSyncProvider>().ToSelf().InSingletonScope();
_kernel.Bind<ISeasonProvider>().To<SeasonProvider>();
_kernel.Bind<IEpisodeProvider>().To<EpisodeProvider>();
_kernel.Bind<UpcomingEpisodesProvider>().To<UpcomingEpisodesProvider>();
_kernel.Bind<IDiskProvider>().To<DiskProvider>();
_kernel.Bind<UpcomingEpisodesProvider>().ToSelf();
_kernel.Bind<DiskProvider>().ToSelf();
_kernel.Bind<SabProvider>().ToSelf();
_kernel.Bind<HistoryProvider>().ToSelf();
_kernel.Bind<RootDirProvider>().ToSelf();
@ -74,7 +74,7 @@ namespace NzbDrone.Core
_kernel.Bind<PostProcessingProvider>().ToSelf();
_kernel.Bind<IConfigProvider>().To<ConfigProvider>().InSingletonScope();
_kernel.Bind<ISyncProvider>().To<SyncProvider>().InSingletonScope();
_kernel.Bind<IIndexerProvider>().To<IndexerProvider>().InSingletonScope();
_kernel.Bind<IndexerProvider>().ToSelf().InSingletonScope();
_kernel.Bind<RenameProvider>().ToSelf().InSingletonScope();
_kernel.Bind<NotificationProvider>().ToSelf().InSingletonScope();
_kernel.Bind<ILogProvider>().To<LogProvider>().InSingletonScope();

View File

@ -183,7 +183,6 @@
<Compile Include="Providers\Feed\NzbsOrgFeedProvider.cs" />
<Compile Include="Providers\HistoryProvider.cs" />
<Compile Include="Providers\BacklogProvider.cs" />
<Compile Include="Providers\IIndexerProvider.cs" />
<Compile Include="Providers\IndexerProvider.cs" />
<Compile Include="Providers\RssSyncProvider.cs" />
<Compile Include="Providers\PostProcessingProvider.cs" />
@ -227,7 +226,6 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Providers\Core\DiskProvider.cs" />
<Compile Include="Providers\Core\IConfigProvider.cs" />
<Compile Include="Providers\Core\IDiskProvider.cs" />
<Compile Include="Providers\SeriesProvider.cs" />
<Compile Include="Providers\TvDbProvider.cs" />
</ItemGroup>

View File

@ -3,48 +3,48 @@ using System.IO;
namespace NzbDrone.Core.Providers.Core
{
public class DiskProvider : IDiskProvider
public class DiskProvider
{
#region IDiskProvider Members
public bool FolderExists(string path)
public virtual bool FolderExists(string path)
{
return Directory.Exists(path);
}
public bool FileExists(string path)
public virtual bool FileExists(string path)
{
return File.Exists(path);
}
public string[] GetDirectories(string path)
public virtual string[] GetDirectories(string path)
{
return Directory.GetDirectories(path);
}
public string[] GetFiles(string path, string pattern, SearchOption searchOption)
public virtual string[] GetFiles(string path, string pattern, SearchOption searchOption)
{
return Directory.GetFiles(path, pattern, searchOption);
}
public long GetSize(string path)
public virtual long GetSize(string path)
{
var fi = new FileInfo(path);
return fi.Length;
//return new FileInfo(path).Length;
}
public String CreateDirectory(string path)
public virtual String CreateDirectory(string path)
{
return Directory.CreateDirectory(path).FullName;
}
public void DeleteFile(string path)
public virtual void DeleteFile(string path)
{
File.Delete(path);
}
public void RenameFile(string sourcePath, string destinationPath)
public virtual void RenameFile(string sourcePath, string destinationPath)
{
File.Move(sourcePath, destinationPath);
}

View File

@ -1,17 +0,0 @@
using System;
using System.IO;
namespace NzbDrone.Core.Providers.Core
{
public interface IDiskProvider
{
bool FolderExists(string path);
string[] GetDirectories(string path);
String CreateDirectory(string path);
string[] GetFiles(string path, string pattern, SearchOption searchOption);
bool FileExists(string path);
long GetSize(string path);
void DeleteFile(string path);
void RenameFile(string sourcePath, string destinationPath);
}
}

View File

@ -1,17 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Providers
{
public interface IIndexerProvider
{
List<Indexer> AllIndexers();
List<Indexer> EnabledIndexers();
void Update(Indexer indexer);
Indexer Single(int indexerId);
}
}

View File

@ -11,7 +11,7 @@ using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Providers
{
public class IndexerProvider : IIndexerProvider
public class IndexerProvider
{
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly IRepository _sonicRepo;
@ -23,24 +23,24 @@ namespace NzbDrone.Core.Providers
_configProvider = configProvider;
}
#region IIndexerProvider Members
#region IndexerProvider Members
public List<Indexer> AllIndexers()
public virtual List<Indexer> AllIndexers()
{
return _sonicRepo.All<Indexer>().OrderBy(i => i.Order).ToList();
}
public List<Indexer> EnabledIndexers()
public virtual List<Indexer> EnabledIndexers()
{
return _sonicRepo.All<Indexer>().Where(i => i.Enabled).OrderBy(i => i.Order).ToList();
}
public void Update(Indexer indexer)
public virtual void Update(Indexer indexer)
{
_sonicRepo.Update(indexer);
}
public Indexer Single(int indexerId)
public virtual Indexer Single(int indexerId)
{
return _sonicRepo.Single<Indexer>(indexerId);
}

View File

@ -16,13 +16,13 @@ namespace NzbDrone.Core.Providers
{
private readonly IRepository _repository;
private readonly IConfigProvider _configProvider;
private readonly IDiskProvider _diskProvider;
private readonly DiskProvider _diskProvider;
private readonly IEpisodeProvider _episodeProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private static readonly string[] MediaExtentions = new[] { "*.mkv", "*.avi", "*.wmv" };
public MediaFileProvider(IRepository repository, IConfigProvider configProvider, IDiskProvider diskProvider, IEpisodeProvider episodeProvider)
public MediaFileProvider(IRepository repository, IConfigProvider configProvider, DiskProvider diskProvider, IEpisodeProvider episodeProvider)
{
_repository = repository;
_configProvider = configProvider;

View File

@ -18,7 +18,7 @@ namespace NzbDrone.Core.Providers
private readonly ISeasonProvider _seasonProvider;
private readonly IEpisodeProvider _episodeProvider;
private readonly IMediaFileProvider _mediaFileProvider;
private readonly IDiskProvider _diskProvider;
private readonly DiskProvider _diskProvider;
private readonly IConfigProvider _configProvider;
private readonly ExternalNotificationProvider _externalNotificationProvider;
@ -29,7 +29,7 @@ namespace NzbDrone.Core.Providers
public RenameProvider(SeriesProvider seriesProvider, ISeasonProvider seasonProvider,
IEpisodeProvider episodeProvider, IMediaFileProvider mediaFileProvider,
IDiskProvider diskProvider, IConfigProvider configProvider,
DiskProvider diskProvider, IConfigProvider configProvider,
ExternalNotificationProvider extenalNotificationProvider)
{
_seriesProvider = seriesProvider;

View File

@ -17,7 +17,7 @@ namespace NzbDrone.Core.Providers
private readonly IEpisodeProvider _episodeProvider;
private readonly IMediaFileProvider _mediaFileProvider;
private readonly NotificationProvider _notificationProvider;
private readonly IDiskProvider _diskProvider;
private readonly DiskProvider _diskProvider;
private ProgressNotification _seriesSyncNotification;
private Thread _seriesSyncThread;
@ -26,7 +26,7 @@ namespace NzbDrone.Core.Providers
public SyncProvider(SeriesProvider seriesProvider, IEpisodeProvider episodeProvider,
IMediaFileProvider mediaFileProvider, NotificationProvider notificationProvider,
IDiskProvider diskProvider)
DiskProvider diskProvider)
{
_seriesProvider = seriesProvider;
_episodeProvider = episodeProvider;

View File

@ -20,7 +20,7 @@ namespace NzbDrone.Web.Controllers
public class SettingsController : Controller
{
private IConfigProvider _configProvider;
private IIndexerProvider _indexerProvider;
private IndexerProvider _indexerProvider;
private QualityProvider _qualityProvider;
private RootDirProvider _rootDirProvider;
@ -28,7 +28,7 @@ namespace NzbDrone.Web.Controllers
private const string SETTINGS_SAVED = "Settings Saved.";
private const string SETTINGS_FAILED = "Error Saving Settings, please fix any errors";
public SettingsController(IConfigProvider configProvider, IIndexerProvider indexerProvider,
public SettingsController(IConfigProvider configProvider, IndexerProvider indexerProvider,
QualityProvider qualityProvider, RootDirProvider rootDirProvider)
{
_configProvider = configProvider;