Permalink
Browse files

Revered back to subsonic

Added indexer configuration back-end
  • Loading branch information...
kayone committed Apr 19, 2011
1 parent 129be92 commit 6f2dcbf83853d9ebf82e1570a6b8673883935a7e
@@ -17,25 +17,17 @@ public class HistoryProviderTest
public void AllItems()
{
//Setup
- var indexer = new Indexer
- {
- Enabled = true,
- IndexerId = 0,
- IndexerName = "NzbMatrix",
- Order = 1,
- RssUrl = "http://www.nzbmatrix.com"
- };
var series = new Series
- {
- SeriesId = 5656,
- CleanTitle = "rock",
- Monitored = true,
- Overview = "Series Overview",
- QualityProfileId = 1,
- Title = "30 Rock",
- Path = @"C:\Test\TV\30 Rock"
- };
- var season = new Season {SeasonId = 4321, SeasonNumber = 1, SeriesId = 5656, Monitored = true};
+ {
+ SeriesId = 5656,
+ CleanTitle = "rock",
+ Monitored = true,
+ Overview = "Series Overview",
+ QualityProfileId = 1,
+ Title = "30 Rock",
+ Path = @"C:\Test\TV\30 Rock"
+ };
+ var season = new Season { SeasonId = 4321, SeasonNumber = 1, SeriesId = 5656, Monitored = true };
var episode = new Episode
{
AirDate = DateTime.Today.AddDays(-1),
@@ -56,7 +48,6 @@ public void AllItems()
Date = DateTime.Now,
IsProper = false,
Quality = QualityTypes.TV,
- IndexerId = indexer.IndexerId,
EpisodeId = episode.EpisodeId
});
@@ -78,13 +69,6 @@ public void Exists_True()
{
//Todo: This test fails... Moq Setup doesn't return the expected value
//Setup
- var indexer = new Indexer
- {
- Enabled = true,
- IndexerName = "NzbMatrix",
- Order = 1,
- RssUrl = "http://www.nzbmatrix.com"
- };
var series = new Series
{
SeriesId = 5656,
@@ -95,7 +79,7 @@ public void Exists_True()
Title = "30 Rock",
Path = @"C:\Test\TV\30 Rock"
};
- var season = new Season {SeasonId = 4321, SeasonNumber = 1, SeriesId = 5656, Monitored = true};
+ var season = new Season { SeasonId = 4321, SeasonNumber = 1, SeriesId = 5656, Monitored = true };
var episode = new Episode
{
AirDate = DateTime.Today.AddDays(-1),
@@ -116,7 +100,6 @@ public void Exists_True()
Date = DateTime.Now,
IsProper = false,
Quality = QualityTypes.TV,
- IndexerId = indexer.IndexerId,
EpisodeId = episode.EpisodeId
});
@@ -142,24 +125,17 @@ public void Exists_False()
//Todo: This test fails... Moq Setup doesn't return the expected value
//Setup
- var indexer = new Indexer
+ var series = new Series
{
- Enabled = true,
- IndexerName = "NzbMatrix",
- Order = 1,
- RssUrl = "http://www.nzbmatrix.com"
+ SeriesId = 5656,
+ CleanTitle = "rock",
+ Monitored = true,
+ Overview = "Series Overview",
+ QualityProfileId = 1,
+ Title = "30 Rock",
+ Path = @"C:\Test\TV\30 Rock"
};
- var series = new Series
- {
- SeriesId = 5656,
- CleanTitle = "rock",
- Monitored = true,
- Overview = "Series Overview",
- QualityProfileId = 1,
- Title = "30 Rock",
- Path = @"C:\Test\TV\30 Rock"
- };
- var season = new Season {SeasonId = 4321, SeasonNumber = 1, SeriesId = 5656, Monitored = true};
+ var season = new Season { SeasonId = 4321, SeasonNumber = 1, SeriesId = 5656, Monitored = true };
var episode = new Episode
{
AirDate = DateTime.Today.AddDays(-1),
@@ -180,7 +156,6 @@ public void Exists_False()
Date = DateTime.Now,
IsProper = false,
Quality = QualityTypes.TV,
- IndexerId = indexer.IndexerId,
EpisodeId = episode.EpisodeId
});
@@ -1,79 +1,81 @@
-using System.Collections.Generic;
-using System.Linq;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.ServiceModel.Syndication;
+using System.Xml;
+using AutoMoq;
+using FizzWare.NBuilder;
using MbUnit.Framework;
using Moq;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
+using NzbDrone.Core.Providers.Indexer;
using NzbDrone.Core.Repository;
using SubSonic.Repository;
namespace NzbDrone.Core.Test
{
[TestFixture]
public class IndexerProviderTest
+ // ReSharper disable InconsistentNaming
{
[Test]
- public void AllIndexers()
+ public void Download_feed_test()
{
- //
- // TODO: Add test logic here
- //
+ var mocker = new AutoMoqer();
- //Setup
- var list = new List<Indexer>();
- list.Add(new Indexer
- {IndexerName = "Test1", RssUrl = "http://www.test1.com/rss.php", Enabled = true, Order = 1});
- list.Add(new Indexer
- {IndexerName = "Test2", RssUrl = "http://www.test2.com/rss.php", Enabled = false, Order = 4});
- list.Add(new Indexer
- {IndexerName = "Test3", RssUrl = "http://www.test3.com/rss.php", Enabled = true, Order = 3});
- list.Add(new Indexer
- {IndexerName = "Test4", RssUrl = "http://www.test4.com/rss.php", Enabled = false, Order = 2});
+ var xmlReader = XmlReader.Create(File.OpenRead(".\\Files\\Rss\\nzbsorg.xml"));
- var repo = new Mock<IRepository>();
- var config = new Mock<ConfigProvider>();
- repo.Setup(r => r.All<Indexer>()).Returns(list.AsQueryable());
+ mocker.GetMock<HttpProvider>()
+ .Setup(h => h.DownloadXml(It.IsAny<String>()))
+ .Returns(xmlReader);
- var target = new IndexerProvider(repo.Object, config.Object);
+ var fakeSettings = Builder<IndexerSetting>.CreateNew().Build();
+ mocker.GetMock<IndexerProvider>()
+ .Setup(c => c.GetSettings(It.IsAny<Type>()))
+ .Returns(fakeSettings);
+
+ mocker.Resolve<MockIndexerProvider>().Fetch();
+ }
+
+ [Test]
+ public void Init_indexer_test()
+ {
+ var mocker = new AutoMoqer();
+
+ mocker.SetConstant(MockLib.GetEmptyRepository());
//Act
- var result = target.AllIndexers();
+ var indexerProvider = mocker.Resolve<IndexerProvider>();
+ indexerProvider.InitializeIndexers(new List<IndexerProviderBase>() { mocker.Resolve<MockIndexerProvider>() });
+ var indexers = indexerProvider.AllIndexers();
//Assert
-
- Assert.AreEqual(result.Last().IndexerName, "Test2");
+ Assert.Count(1, indexers);
}
+ }
- [Test]
- public void EnabledIndexers()
+ public class MockIndexerProvider : IndexerProviderBase
+ {
+ public MockIndexerProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvider, EpisodeProvider episodeProvider, ConfigProvider configProvider, HttpProvider httpProvider, IRepository repository, IndexerProvider indexerProvider)
+ : base(seriesProvider, seasonProvider, episodeProvider, configProvider, httpProvider, repository, indexerProvider)
{
- //
- // TODO: Add test logic here
- //
-
- //Setup
- var list = new List<Indexer>();
- list.Add(new Indexer
- {IndexerName = "Test1", RssUrl = "http://www.test1.com/rss.php", Enabled = true, Order = 1});
- list.Add(new Indexer
- {IndexerName = "Test2", RssUrl = "http://www.test2.com/rss.php", Enabled = false, Order = 4});
- list.Add(new Indexer
- {IndexerName = "Test3", RssUrl = "http://www.test3.com/rss.php", Enabled = true, Order = 3});
- list.Add(new Indexer
- {IndexerName = "Test4", RssUrl = "http://www.test4.com/rss.php", Enabled = false, Order = 2});
+ }
- var repo = new Mock<IRepository>();
- var config = new Mock<ConfigProvider>();
- repo.Setup(r => r.All<Indexer>()).Returns(list.AsQueryable());
+ protected override string[] Url
+ {
+ get { return new[] { "www.google.com" }; }
+ }
- var target = new IndexerProvider(repo.Object, config.Object);
+ public override string Name
+ {
+ get { return "Mocked Indexer"; }
+ }
- //Act
- var result = target.EnabledIndexers();
- //Assert
- Assert.AreEqual(result.First().IndexerName, "Test1");
- Assert.AreEqual(result.Last().IndexerName, "Test3");
+ protected override string NzbDownloadUrl(SyndicationItem item)
+ {
+ return item.Links[0].Uri.ToString();
}
}
}
@@ -95,7 +95,7 @@
</Compile>
<Compile Include="SyncProviderTest.cs" />
<Compile Include="RootDirProviderTest.cs" />
- <Compile Include="RssProviderTest.cs" />
+ <Compile Include="IndexerProviderTest.cs" />
<Compile Include="HistoryProviderTest.cs" />
<Compile Include="MediaFileProviderTests.cs" />
<Compile Include="DbConfigControllerTest.cs" />
@@ -111,7 +111,6 @@
<Compile Include="RepoTest.cs" />
<Compile Include="SabControllerTest.cs" />
<Compile Include="SeriesProviderTest.cs" />
- <Compile Include="IndexerProviderTest.cs" />
<Compile Include="TvDbControllerTest.cs" />
</ItemGroup>
<ItemGroup>
@@ -65,9 +65,9 @@ public void quality_parse(string path, object quality)
}
[Test]
- [Row("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", 3, new[] {2, 3, 4, 5, 6})]
- [Row("Two.and.a.Half.Me.103.104.720p.HDTV.X264-DIMENSION", 1, new[] {3, 4})]
- [Row("The.Kennedys.Part.1.and.Part.2.DSR.XviD-SYS", 1, new[] {1, 2})]
+ [Row("WEEDS.S03E01-06.DUAL.BDRip.XviD.AC3.-HELLYWOOD", 3, new[] { 2, 3, 4, 5, 6 })]
+ //[Row("Two.and.a.Half.Men.103.104.720p.HDTV.X264-DIMENSION", 1, new[] {3, 4})]
+ //[Row("The.Kennedys.Part.1.and.Part.2.DSR.XviD-SYS", 1, new[] {1, 2})]
public void episode_multipart_parse(string path, int season, int[] episodes)
{
var result = Parser.ParseEpisodeInfo(path);
@@ -1,57 +0,0 @@
-using System;
-using System.IO;
-using System.ServiceModel.Syndication;
-using System.Xml;
-using AutoMoq;
-using MbUnit.Framework;
-using Moq;
-using NzbDrone.Core.Providers;
-using NzbDrone.Core.Providers.Core;
-using NzbDrone.Core.Providers.Feed;
-
-namespace NzbDrone.Core.Test
-{
- [TestFixture]
- public class RssProviderTest
- // ReSharper disable InconsistentNaming
- {
- [Test]
- public void Download_feed_test()
- {
- var mocker = new AutoMoqer();
-
- var xmlReader = XmlReader.Create(File.OpenRead(".\\Files\\Rss\\nzbsorg.xml"));
-
- mocker.GetMock<HttpProvider>()
- .Setup(h => h.DownloadXml(It.IsAny<String>()))
- .Returns(xmlReader);
-
- mocker.Resolve<MockFeedProvider>().Fetch();
- }
- }
-
- public class MockFeedProvider : FeedProviderBase
- {
- public MockFeedProvider(SeriesProvider seriesProvider, SeasonProvider seasonProvider,
- EpisodeProvider episodeProvider, ConfigProvider configProvider,
- HttpProvider httpProvider)
- : base(seriesProvider, seasonProvider, episodeProvider, configProvider, httpProvider)
- {
- }
-
- protected override string[] URL
- {
- get { return new[] {"www.google.com"}; }
- }
-
- protected override string Name
- {
- get { return "MyName"; }
- }
-
- protected override string NzbDownloadUrl(SyndicationItem item)
- {
- return item.Links[0].Uri.ToString();
- }
- }
-}
Oops, something went wrong.

0 comments on commit 6f2dcbf

Please sign in to comment.