diff --git a/NzbDrone.Core.Test/FluentTest.cs b/NzbDrone.Core.Test/FluentTest.cs
index 30bba6559..bed081666 100644
--- a/NzbDrone.Core.Test/FluentTest.cs
+++ b/NzbDrone.Core.Test/FluentTest.cs
@@ -1,19 +1,7 @@
using System;
using System.IO;
-using System.Linq;
-using System.Net;
-using System.ServiceModel.Syndication;
-using AutoMoq;
-using FizzWare.NBuilder;
using FluentAssertions;
-using Moq;
using NUnit.Framework;
-using NzbDrone.Core.Model;
-using NzbDrone.Core.Providers;
-using NzbDrone.Core.Providers.Core;
-using NzbDrone.Core.Providers.Indexer;
-using NzbDrone.Core.Repository;
-using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test
diff --git a/NzbDrone.Core.Test/Framework/Fixtures.cs b/NzbDrone.Core.Test/Framework/Fixtures.cs
index 30e514579..2a04a3717 100644
--- a/NzbDrone.Core.Test/Framework/Fixtures.cs
+++ b/NzbDrone.Core.Test/Framework/Fixtures.cs
@@ -3,48 +3,46 @@ using System.IO;
using NLog;
using NLog.Config;
using NUnit.Framework;
+using NzbDrone.Core;
using NzbDrone.Core.Test.Framework;
-namespace NzbDrone.Core.Test
+[SetUpFixture]
+public class Fixtures
{
- [SetUpFixture]
- public class Fixtures
+ [TearDown]
+ public void TearDown()
{
- [TearDown]
- public void TearDown()
+
+ }
+
+ [SetUp]
+ public void SetUp()
+ {
+ try
{
+ LogManager.Configuration = new XmlLoggingConfiguration(Path.Combine(CentralDispatch.AppPath, "log.config"), false);
+ LogManager.ThrowExceptions = true;
+ var exceptionVerification = new ExceptionVerification();
+ LogManager.Configuration.AddTarget("ExceptionVerification", exceptionVerification);
+ LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Info, exceptionVerification));
+ LogManager.Configuration.Reload();
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Unable to configure logging. " + e);
}
- [SetUp]
- public void SetUp()
+ var filesToDelete = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.sdf", SearchOption.AllDirectories);
+ foreach (var file in filesToDelete)
{
try
{
- LogManager.Configuration = new XmlLoggingConfiguration(Path.Combine(CentralDispatch.AppPath, "log.config"), false);
- LogManager.ThrowExceptions = true;
-
- var exceptionVerification = new ExceptionVerification();
- LogManager.Configuration.AddTarget("ExceptionVerification", exceptionVerification);
- LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Info, exceptionVerification));
- LogManager.Configuration.Reload();
- }
- catch (Exception e)
- {
- Console.WriteLine("Unable to configure logging. " + e);
+ File.Delete(file);
}
-
- var filesToDelete = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.sdf", SearchOption.AllDirectories);
- foreach (var file in filesToDelete)
- {
- try
- {
- File.Delete(file);
- }
- catch { }
- }
-
- MockLib.CreateDataBaseTemplate();
+ catch { }
}
+
+ MockLib.CreateDataBaseTemplate();
}
-}
\ No newline at end of file
+}
diff --git a/NzbDrone.Core.Test/IndexerTests.cs b/NzbDrone.Core.Test/IndexerTests.cs
index 40ab07a1a..1d8ce1a7b 100644
--- a/NzbDrone.Core.Test/IndexerTests.cs
+++ b/NzbDrone.Core.Test/IndexerTests.cs
@@ -15,6 +15,7 @@ using NzbDrone.Core.Providers.Indexer;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
+using NzbDrone.Core.Test.ProviderTests;
namespace NzbDrone.Core.Test
{
diff --git a/NzbDrone.Core.Test/BacklogSearchJobTest.cs b/NzbDrone.Core.Test/JobTests/BacklogSearchJobTest.cs
similarity index 98%
rename from NzbDrone.Core.Test/BacklogSearchJobTest.cs
rename to NzbDrone.Core.Test/JobTests/BacklogSearchJobTest.cs
index be5a9dd1a..ab29338af 100644
--- a/NzbDrone.Core.Test/BacklogSearchJobTest.cs
+++ b/NzbDrone.Core.Test/JobTests/BacklogSearchJobTest.cs
@@ -1,18 +1,15 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
-using System.Text;
using AutoMoq;
using FizzWare.NBuilder;
using Moq;
using NUnit.Framework;
-using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Jobs;
using NzbDrone.Core.Repository;
-namespace NzbDrone.Core.Test
+namespace NzbDrone.Core.Test.JobTests
{
[TestFixture]
public class BacklogSearchJobTest
diff --git a/NzbDrone.Core.Test/BannerDownloadJobTest.cs b/NzbDrone.Core.Test/JobTests/BannerDownloadJobTest.cs
similarity index 97%
rename from NzbDrone.Core.Test/BannerDownloadJobTest.cs
rename to NzbDrone.Core.Test/JobTests/BannerDownloadJobTest.cs
index ec26d1ed8..57d157ec1 100644
--- a/NzbDrone.Core.Test/BannerDownloadJobTest.cs
+++ b/NzbDrone.Core.Test/JobTests/BannerDownloadJobTest.cs
@@ -1,22 +1,16 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
+using System.IO;
using AutoMoq;
using FizzWare.NBuilder;
-using FluentAssertions;
using Moq;
using NUnit.Framework;
-using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
-using NzbDrone.Core.Providers.Indexer;
using NzbDrone.Core.Providers.Jobs;
using NzbDrone.Core.Repository;
-using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
-namespace NzbDrone.Core.Test
+namespace NzbDrone.Core.Test.JobTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
diff --git a/NzbDrone.Core.Test/DiskScanJobTest.cs b/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs
similarity index 99%
rename from NzbDrone.Core.Test/DiskScanJobTest.cs
rename to NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs
index 2e372ee6d..2f840d651 100644
--- a/NzbDrone.Core.Test/DiskScanJobTest.cs
+++ b/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs
@@ -1,4 +1,5 @@
// ReSharper disable RedundantUsingDirective
+
using System;
using System.Collections.Generic;
using AutoMoq;
@@ -11,7 +12,7 @@ using NzbDrone.Core.Providers.Jobs;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
-namespace NzbDrone.Core.Test
+namespace NzbDrone.Core.Test.JobTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
diff --git a/NzbDrone.Core.Test/ImportNewSeriesJobTest.cs b/NzbDrone.Core.Test/JobTests/ImportNewSeriesJobTest.cs
similarity index 99%
rename from NzbDrone.Core.Test/ImportNewSeriesJobTest.cs
rename to NzbDrone.Core.Test/JobTests/ImportNewSeriesJobTest.cs
index d64dc057c..72ba0f55d 100644
--- a/NzbDrone.Core.Test/ImportNewSeriesJobTest.cs
+++ b/NzbDrone.Core.Test/JobTests/ImportNewSeriesJobTest.cs
@@ -1,4 +1,5 @@
// ReSharper disable RedundantUsingDirective
+
using System;
using System.Collections.Generic;
using AutoMoq;
@@ -11,8 +12,8 @@ using NzbDrone.Core.Providers.Jobs;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
-namespace NzbDrone.Core.Test
-{
+namespace NzbDrone.Core.Test.JobTests
+{
[TestFixture]
// ReSharper disable InconsistentNaming
public class ImportNewSeriesJobTest : TestBase
diff --git a/NzbDrone.Core.Test/SearchJobTest.cs b/NzbDrone.Core.Test/JobTests/SearchJobTest.cs
similarity index 88%
rename from NzbDrone.Core.Test/SearchJobTest.cs
rename to NzbDrone.Core.Test/JobTests/SearchJobTest.cs
index 0e06c85f0..36bdcba25 100644
--- a/NzbDrone.Core.Test/SearchJobTest.cs
+++ b/NzbDrone.Core.Test/JobTests/SearchJobTest.cs
@@ -1,14 +1,11 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
+using System;
using AutoMoq;
using Moq;
using NUnit.Framework;
using NzbDrone.Core.Model.Notification;
-using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Jobs;
-namespace NzbDrone.Core.Test
+namespace NzbDrone.Core.Test.JobTests
{
[TestFixture]
public class SearchJobTest
diff --git a/NzbDrone.Core.Test/SeasonSearchJobTest.cs b/NzbDrone.Core.Test/JobTests/SeasonSearchJobTest.cs
similarity index 95%
rename from NzbDrone.Core.Test/SeasonSearchJobTest.cs
rename to NzbDrone.Core.Test/JobTests/SeasonSearchJobTest.cs
index 85b62c517..cf6edf385 100644
--- a/NzbDrone.Core.Test/SeasonSearchJobTest.cs
+++ b/NzbDrone.Core.Test/JobTests/SeasonSearchJobTest.cs
@@ -1,21 +1,16 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using AutoMoq;
using FizzWare.NBuilder;
-using FluentAssertions;
using Moq;
using NUnit.Framework;
-using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
-using NzbDrone.Core.Providers.Indexer;
using NzbDrone.Core.Providers.Jobs;
using NzbDrone.Core.Repository;
-using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
-namespace NzbDrone.Core.Test
+namespace NzbDrone.Core.Test.JobTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
diff --git a/NzbDrone.Core.Test/SeriesSearchJobTest.cs b/NzbDrone.Core.Test/JobTests/SeriesSearchJobTest.cs
similarity index 88%
rename from NzbDrone.Core.Test/SeriesSearchJobTest.cs
rename to NzbDrone.Core.Test/JobTests/SeriesSearchJobTest.cs
index 0f64beef3..ad9c148cc 100644
--- a/NzbDrone.Core.Test/SeriesSearchJobTest.cs
+++ b/NzbDrone.Core.Test/JobTests/SeriesSearchJobTest.cs
@@ -1,20 +1,13 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using AutoMoq;
-using FizzWare.NBuilder;
-using FluentAssertions;
using Moq;
using NUnit.Framework;
-using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
-using NzbDrone.Core.Providers.Indexer;
using NzbDrone.Core.Providers.Jobs;
-using NzbDrone.Core.Repository;
-using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
-namespace NzbDrone.Core.Test
+namespace NzbDrone.Core.Test.JobTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
index 969874d1a..d151323cd 100644
--- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
+++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
@@ -88,41 +88,41 @@
-
-
-
+
+
+
-
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
+
+
-
+
Code
@@ -131,23 +131,23 @@
Code
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
-
+
+
diff --git a/NzbDrone.Core.Test/ConfigFileProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/ConfigFileProviderTest.cs
similarity index 98%
rename from NzbDrone.Core.Test/ConfigFileProviderTest.cs
rename to NzbDrone.Core.Test/ProviderTests/ConfigFileProviderTest.cs
index abbfb8e4c..704fc9857 100644
--- a/NzbDrone.Core.Test/ConfigFileProviderTest.cs
+++ b/NzbDrone.Core.Test/ProviderTests/ConfigFileProviderTest.cs
@@ -4,10 +4,9 @@ using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
-using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
-namespace NzbDrone.Core.Test
+namespace NzbDrone.Core.Test.ProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
diff --git a/NzbDrone.Core.Test/ConfigProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/ConfigProviderTest.cs
similarity index 98%
rename from NzbDrone.Core.Test/ConfigProviderTest.cs
rename to NzbDrone.Core.Test/ProviderTests/ConfigProviderTest.cs
index 14c93ea98..3200202c4 100644
--- a/NzbDrone.Core.Test/ConfigProviderTest.cs
+++ b/NzbDrone.Core.Test/ProviderTests/ConfigProviderTest.cs
@@ -5,7 +5,7 @@ using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
-namespace NzbDrone.Core.Test
+namespace NzbDrone.Core.Test.ProviderTests
{
[TestFixture]
// ReSharper disable InconsistentNaming
diff --git a/NzbDrone.Core.Test/DiskScanProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest.cs
similarity index 96%
rename from NzbDrone.Core.Test/DiskScanProviderTest.cs
rename to NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest.cs
index efe556039..c00f22c39 100644
--- a/NzbDrone.Core.Test/DiskScanProviderTest.cs
+++ b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest.cs
@@ -2,18 +2,14 @@
using System.Collections.Generic;
using AutoMoq;
using FizzWare.NBuilder;
-using FluentAssertions;
using Moq;
using NUnit.Framework;
-using NzbDrone.Core.Model;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
-using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
-using PetaPoco;
-namespace NzbDrone.Core.Test
+namespace NzbDrone.Core.Test.ProviderTests
{
// ReSharper disable InconsistentNaming
public class DiskScanProviderTest : TestBase
diff --git a/NzbDrone.Core.Test/DiskScanProviderTest_ImportFile.cs b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest_ImportFile.cs
similarity index 99%
rename from NzbDrone.Core.Test/DiskScanProviderTest_ImportFile.cs
rename to NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest_ImportFile.cs
index bf673758d..e8b58fabb 100644
--- a/NzbDrone.Core.Test/DiskScanProviderTest_ImportFile.cs
+++ b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTest_ImportFile.cs
@@ -11,9 +11,8 @@ using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality;
using NzbDrone.Core.Test.Framework;
-using PetaPoco;
-namespace NzbDrone.Core.Test
+namespace NzbDrone.Core.Test.ProviderTests
{
// ReSharper disable InconsistentNaming
public class DiskScanProviderTest_ImportFile : TestBase
diff --git a/NzbDrone.Core.Test/DownloadProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/DownloadProviderTest.cs
similarity index 98%
rename from NzbDrone.Core.Test/DownloadProviderTest.cs
rename to NzbDrone.Core.Test/ProviderTests/DownloadProviderTest.cs
index 0dd86d5fc..14e5b2b5c 100644
--- a/NzbDrone.Core.Test/DownloadProviderTest.cs
+++ b/NzbDrone.Core.Test/ProviderTests/DownloadProviderTest.cs
@@ -11,7 +11,7 @@ using NzbDrone.Core.Test.Framework;
// ReSharper disable InconsistentNaming
-namespace NzbDrone.Core.Test
+namespace NzbDrone.Core.Test.ProviderTests
{
[TestFixture]
public class DownloadProviderTest : TestBase
diff --git a/NzbDrone.Core.Test/EpisodeProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest.cs
similarity index 97%
rename from NzbDrone.Core.Test/EpisodeProviderTest.cs
rename to NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest.cs
index 80d0ff895..f6b02895c 100644
--- a/NzbDrone.Core.Test/EpisodeProviderTest.cs
+++ b/NzbDrone.Core.Test/ProviderTests/EpisodeProviderTest.cs
@@ -1,1543 +1,1543 @@
-// ReSharper disable RedundantUsingDirective
-using System;
-using System.Collections.Generic;
-using System.Data.SqlServerCe;
-using System.Linq;
-using AutoMoq;
-using FizzWare.NBuilder;
-using FluentAssertions;
-using Moq;
-using NUnit.Framework;
-using NzbDrone.Core.Model;
-using NzbDrone.Core.Providers;
-using NzbDrone.Core.Providers.Core;
-using NzbDrone.Core.Repository;
-using NzbDrone.Core.Repository.Quality;
-using NzbDrone.Core.Test.Framework;
-using PetaPoco;
-using TvdbLib.Data;
-
-namespace NzbDrone.Core.Test
-{
- [TestFixture]
- // ReSharper disable InconsistentNaming
- public class EpisodeProviderTest : TestBase
- {
- [Test]
- public void GetEpisodes_exists()
- {
- var mocker = new AutoMoqer();
- var db = MockLib.GetEmptyDatabase();
- mocker.SetConstant(db);
-
- var fakeSeries = Builder.CreateNew().Build();
- var fakeEpisodes = Builder.CreateListOfSize(5)
- .All().With(e => e.SeriesId = 1).With(e => e.EpisodeFileId = 0).Build();
-
- db.Insert(fakeSeries);
- db.InsertMany(fakeEpisodes);
-
- //Act
- var episode = mocker.Resolve().GetEpisode(1);
-
- //Assert
- episode.ShouldHave().AllPropertiesBut(e => e.Series, e => e.EpisodeFile).EqualTo(fakeEpisodes.First());
- episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount, s => s.NextAiring).EqualTo(fakeSeries);
- }
-
- [Test]
- public void GetEpisodes_by_season_episode_exists()
- {
- var mocker = new AutoMoqer();
- var db = MockLib.GetEmptyDatabase();
- mocker.SetConstant(db);
-
- var fakeSeries = Builder.CreateNew()
- .With(s => s.SeriesId = 1)
- .Build();
- var fakeEpisodes = Builder.CreateNew()
- .With(e => e.SeriesId = 1)
- .With(e => e.EpisodeNumber = 1)
- .And(e => e.SeasonNumber = 2)
- .With(e => e.EpisodeFileId = 0).Build();
-
- db.Insert(fakeSeries);
- db.Insert(fakeEpisodes);
-
- //Act
- var episode = mocker.Resolve().GetEpisode(fakeSeries.SeriesId, 2, 1);
-
- //Assert
- episode.ShouldHave().AllPropertiesBut(e => e.Series).EqualTo(fakeEpisodes);
- episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount, s => s.NextAiring).EqualTo(fakeSeries);
- }
-
- [Test]
- public void GetEpisodes_by_season_episode_doesnt_exists()
- {
- var mocker = new AutoMoqer();
- var db = MockLib.GetEmptyDatabase();
- mocker.SetConstant(db);
-
-
-
- //Act
- var episode = mocker.Resolve().GetEpisode(1, 1, 1);
-
- //Assert
- episode.Should().BeNull();
- }
-
- [Test]
- public void GetEpisode_with_EpisodeFile()
- {
- var mocker = new AutoMoqer();
- var db = MockLib.GetEmptyDatabase();
- mocker.SetConstant(db);
-
- var fakeSeries = Builder.CreateNew().Build();
- var fakeFile = Builder.CreateNew().With(f => f.EpisodeFileId).Build();
- var fakeEpisodes = Builder.CreateListOfSize(5)
- .All().With(e => e.SeriesId = 1).TheFirst(1).With(e => e.EpisodeFileId = 1).With(e => e.EpisodeFile = fakeFile).Build();
-
- db.Insert(fakeSeries);
- db.InsertMany(fakeEpisodes);
- db.Insert(fakeFile);
-
- //Act
- var episode = mocker.Resolve().GetEpisode(1);
-
- //Assert
- episode.ShouldHave().AllPropertiesBut(e => e.Series, e => e.EpisodeFile).EqualTo(fakeEpisodes.First());
- episode.Series.ShouldHave().AllPropertiesBut(s => s.EpisodeCount, s => s.EpisodeFileCount, s => s.SeasonCount, s => s.NextAiring).EqualTo(fakeSeries);
- episode.EpisodeFile.Should().NotBeNull();
- }
-
- [Test]
- [ExpectedException(typeof(InvalidOperationException), ExpectedMessage = "Sequence contains no elements")]
- public void GetEpisodes_invalid_series()
- {
- var mocker = new AutoMoqer();
- var db = MockLib.GetEmptyDatabase();
- mocker.SetConstant(db);
-
- mocker.Resolve();
-
- var fakeEpisodes = Builder.CreateListOfSize(5)
- .All().With(e => e.SeriesId = 1).Build();
-
-
- db.InsertMany(fakeEpisodes);
-
-
- //Act
- mocker.Resolve().GetEpisode(1);
- }
-
- [Test]
- public void AttachSeries_empty_list()
- {
- var mocker = new AutoMoqer();
-
-
- //Act
- var result = mocker.Resolve().AttachSeries(new List());
-
- //Assert
- result.Should().HaveCount(0);
- }
-
- [Test]
- public void AttachSeries_list_success()
- {
- var mocker = new AutoMoqer();
-
- var fakeSeries = Builder.CreateNew().With(s => s.SeriesId = 12).Build();
- var fakeEpisodes = Builder.CreateListOfSize(5)
- .All().With(e => e.SeriesId = 12).Build();
-
- mocker.GetMock()
- .Setup(c => c.GetSeries(12))
- .Returns(fakeSeries);
-
- //Act
-
- fakeEpisodes.Should().OnlyContain(e => e.Series == null);
- var returnedSeries = mocker.Resolve().AttachSeries(fakeEpisodes);
-
- //Assert
- fakeEpisodes.Should().OnlyContain(e => e.Series == fakeSeries);
- returnedSeries.Should().BeEquivalentTo(fakeEpisodes);
- }
-
- [Test]
- public void AttachSeries_null_episode_should_return_null()
- {
- var mocker = new AutoMoqer();
-
- Episode episode = null;
-
- //Act
- var result = mocker.Resolve().AttachSeries(episode);
-
- //Assert
- result.Should().BeNull();
- }
-
- [Test]
- public void AttachSeries_single_success()
- {
- var mocker = new AutoMoqer();
-
- var fakeSeries = Builder.CreateNew().With(s => s.SeriesId = 12).Build();
- var fakeEpisodes = Builder.CreateNew().With(e => e.SeriesId = 12).Build();
-
- mocker.GetMock()
- .Setup(c => c.GetSeries(12))
- .Returns(fakeSeries);
-
- //Act
- var returnedEpisode = mocker.Resolve().AttachSeries(fakeEpisodes);
-
- //Assert
- fakeEpisodes.Series.Should().Be(fakeSeries);
- returnedEpisode.Should().Be(fakeEpisodes);
- }
-
- [Test]
- [ExpectedException(typeof(InvalidOperationException), ExpectedMessage = "Sequence contains no elements")]
- public void AttachSeries_single_invalid_series()
- {
- var mocker = new AutoMoqer();
- mocker.SetConstant(MockLib.GetEmptyDatabase());
- mocker.Resolve();
- var fakeEpisodes = Builder.CreateNew().With(e => e.SeriesId = 12).Build();
-
- //Act
- var returnedEpisode = mocker.Resolve().AttachSeries(fakeEpisodes);
- }
-
- [Test]
- public void GetEpisodesBySeason_success()
- {
- var fakeSeries = Builder.CreateNew()
- .With(s => s.SeriesId = 12)
- .Build();
-
- var episodes = Builder.CreateListOfSize(10)
- .All().With(c => c.SeriesId = 12).And(c => c.SeasonNumber = 2)
- .TheFirst(5).With(c => c.SeasonNumber = 1)
- .Build();
-
- var db = MockLib.GetEmptyDatabase();
- var mocker = new AutoMoqer();
- mocker.SetConstant(db);
-
- db.Insert(fakeSeries);
- db.InsertMany(episodes);
-
- //Act
- var seasonEposodes = mocker.Resolve().GetEpisodesBySeason(12, 2);
-
- //Assert
- db.Fetch().Should().HaveCount(10);
- seasonEposodes.Should().HaveCount(5);
- }
-
- [Test]
- public void RefreshEpisodeInfo_emptyRepo()
- {
- //Arrange
- const int seriesId = 71663;
- const int episodeCount = 10;
-
- var fakeEpisodes = Builder.CreateNew().With(
- c => c.Episodes =
- new List(Builder.CreateListOfSize(episodeCount).
- All()
- .With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
- .Build())
- ).With(c => c.Id = seriesId).Build();
-
- var fakeSeries = Builder.CreateNew().With(c => c.SeriesId = seriesId).Build();
-
-
- var mocker = new AutoMoqer();
-
- var db = MockLib.GetEmptyDatabase();
- mocker.SetConstant(db);
-
- db.Insert(fakeSeries);
-
- mocker.GetMock()
- .Setup(c => c.GetSeries(seriesId, true))
- .Returns(fakeEpisodes);
-
-
- //Act
- mocker.Resolve().RefreshEpisodeInfo(fakeSeries);
-
- //Assert
- var actualCount = mocker.Resolve().GetEpisodeBySeries(seriesId).ToList().Count;
- mocker.GetMock().VerifyAll();
- actualCount.Should().Be(episodeCount);
- mocker.VerifyAllMocks();
- }
-
- [Test]
- public void RefreshEpisodeInfo_should_set_older_than_1900_to_null()
- {
- //Arrange
- const int seriesId = 71663;
-
- var fakeEpisodes = Builder.CreateNew().With(
- c => c.Episodes =
- new List(Builder.CreateListOfSize(10).
- All()
- .With(l => l.Language = new TvdbLanguage(0, "eng", "a")).And(e => e.FirstAired = DateTime.Now)
- .TheFirst(7).With(e => e.FirstAired = new DateTime(1800, 1, 1))
- .Build())
- ).With(c => c.Id = seriesId).Build();
-
- var fakeSeries = Builder.CreateNew().With(c => c.SeriesId = seriesId).Build();
-
- var mocker = new AutoMoqer();
-
- var db = MockLib.GetEmptyDatabase();
- mocker.SetConstant(db);
-
- db.Insert(fakeSeries);
-
- mocker.GetMock()
- .Setup(c => c.GetSeries(seriesId, true))
- .Returns(fakeEpisodes);
-
-
- //Act
- mocker.Resolve().RefreshEpisodeInfo(fakeSeries);
-
- //Assert
- var storedEpisodes = mocker.Resolve().GetEpisodeBySeries(seriesId).ToList();
- storedEpisodes.Should().HaveCount(10);
- storedEpisodes.Where(e => e.AirDate == null).Should().HaveCount(7);
- storedEpisodes.Where(e => e.AirDate != null).Should().HaveCount(3);
-
- mocker.VerifyAllMocks();
- }
-
- [Test]
- public void RefreshEpisodeInfo_ignore_episode_zero()
- {
- //Arrange
- const int seriesId = 71663;
- const int episodeCount = 10;
-
- var fakeEpisodes = Builder.CreateNew().With(
- c => c.Episodes =
- new List(Builder.CreateListOfSize(episodeCount).
- All()
- .With(l => l.Language = new TvdbLanguage(0, "eng", "a"))
- .TheFirst(1)
- .Has(e => e.EpisodeNumber = 0)
- .Has(e => e.SeasonNumber = 15)
- .Build())
- ).With(c => c.Id = seriesId).Build();
-
- var fakeSeries = Builder.CreateNew().With(c => c.SeriesId = seriesId).Build();
-
- var mocker = new AutoMoqer();
-
- var db = MockLib.GetEmptyDatabase();
- mocker.SetConstant(db);
-
- db.Insert(fakeSeries);
-
- mocker.GetMock()
- .Setup(c => c.GetSeries(seriesId, true))
- .Returns(fakeEpisodes);
-
-
- //Act
- mocker.Resolve().RefreshEpisodeInfo(fakeSeries);
-
- //Assert
- var result = mocker.Resolve().GetEpisodeBySeries(seriesId).ToList();
- mocker.GetMock().VerifyAll();
- result.Should().HaveCount(episodeCount);
- mocker.VerifyAllMocks();
- result.Where(e => e.EpisodeNumber == 0 && e.SeasonNumber == 15).Single().Ignored.Should().BeTrue();
- }
-
- [Test]
- public void new_episodes_only_calls_Insert()
- {
- const int seriesId = 71663;
- var tvdbSeries = Builder.CreateNew()
- .With(c => c.Episodes = new List(Builder.CreateListOfSize(5).Build())
- ).With(c => c.Id = seriesId).Build();
-
- var fakeSeries = Builder.CreateNew().With(c => c.SeriesId = seriesId).Build();
-
- var currentEpisodes = new List();
-
- var mocker = new AutoMoqer();
- var db = MockLib.GetEmptyDatabase();
- mocker.SetConstant(db);
-
- mocker.GetMock(MockBehavior.Strict)
- .Setup(c => c.GetSeries(seriesId, true))
- .Returns(tvdbSeries);
-
- mocker.GetMock()
- .Setup(d => d.Fetch(It.IsAny(), It.IsAny