Fixed broken tests

pull/4/head
Mark McDowall 12 years ago
parent 92acb4c049
commit 41f70ce7ca

@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using FizzWare.NBuilder; using FizzWare.NBuilder;
@ -16,6 +17,19 @@ namespace NzbDrone.Core.Test.ProviderTests
[TestFixture] [TestFixture]
public class SeriesProviderTest : CoreTest public class SeriesProviderTest : CoreTest
{ {
private IList<QualityProfile> _qualityProfiles;
[SetUp]
public void Setup()
{
_qualityProfiles = Builder<QualityProfile>
.CreateListOfSize(2)
.All()
.With(p => p.Cutoff = QualityTypes.DVD)
.With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD })
.Build();
}
[TestCase(true)] [TestCase(true)]
[TestCase(false)] [TestCase(false)]
public void Add_new_series(bool useSeasonFolder) public void Add_new_series(bool useSeasonFolder)
@ -25,7 +39,12 @@ namespace NzbDrone.Core.Test.ProviderTests
Mocker.GetMock<ConfigProvider>() Mocker.GetMock<ConfigProvider>()
.Setup(c => c.UseSeasonFolder).Returns(useSeasonFolder); .Setup(c => c.UseSeasonFolder).Returns(useSeasonFolder);
var fakeProfiles = Builder<QualityProfile>.CreateListOfSize(2).Build(); var fakeProfiles = Builder<QualityProfile>
.CreateListOfSize(2)
.All()
.With(p => p.Cutoff = QualityTypes.DVD)
.With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD })
.Build();
Db.InsertMany(fakeProfiles); Db.InsertMany(fakeProfiles);
@ -96,7 +115,12 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(c => c.EpisodeFileCount = 0) .With(c => c.EpisodeFileCount = 0)
.With(c => c.SeasonCount = 0) .With(c => c.SeasonCount = 0)
.Build(); .Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>
.CreateNew()
.With(p => p.Cutoff = QualityTypes.DVD)
.With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD })
.Build();
Db.Insert(fakeSeries); Db.Insert(fakeSeries);
Db.Insert(fakeQuality); Db.Insert(fakeQuality);
@ -121,7 +145,12 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(c => c.QualityProfileId = 1) .With(c => c.QualityProfileId = 1)
.With(c => c.CleanTitle = "laworder") .With(c => c.CleanTitle = "laworder")
.Build(); .Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeQuality = Builder<QualityProfile>
.CreateNew()
.With(p => p.Cutoff = QualityTypes.DVD)
.With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD })
.Build();
var id = Db.Insert(fakeSeries); var id = Db.Insert(fakeSeries);
Db.Insert(fakeQuality); Db.Insert(fakeQuality);
@ -168,6 +197,8 @@ namespace NzbDrone.Core.Test.ProviderTests
var fakeQuality = Builder<QualityProfile>.CreateNew() var fakeQuality = Builder<QualityProfile>.CreateNew()
.With(c => c.QualityProfileId = fakeSeries.QualityProfileId) .With(c => c.QualityProfileId = fakeSeries.QualityProfileId)
.With(p => p.Cutoff = QualityTypes.DVD)
.With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD })
.Build(); .Build();
Db.Insert(fakeSeries); Db.Insert(fakeSeries);
@ -197,7 +228,11 @@ namespace NzbDrone.Core.Test.ProviderTests
.With(c => c.SeriesId = 11) .With(c => c.SeriesId = 11)
.Build()); .Build());
Db.InsertMany(Builder<QualityProfile>.CreateListOfSize(3).Build()); Db.InsertMany(Builder<QualityProfile>.CreateListOfSize(3)
.All()
.With(p => p.Cutoff = QualityTypes.DVD)
.With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD })
.Build());
//Act, Assert //Act, Assert
var provider = Mocker.Resolve<SeriesProvider>(); var provider = Mocker.Resolve<SeriesProvider>();
@ -211,7 +246,7 @@ namespace NzbDrone.Core.Test.ProviderTests
{ {
WithRealDb(); WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build(); var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(10) var fakeEpisodes = Builder<Episode>.CreateListOfSize(10)
.All().With(e => e.SeriesId = fakeSeries.SeriesId) .All().With(e => e.SeriesId = fakeSeries.SeriesId)
@ -242,7 +277,7 @@ namespace NzbDrone.Core.Test.ProviderTests
{ {
WithRealDb(); WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build(); var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(10).All().With(e => e.SeriesId = fakeSeries.SeriesId).With(e => e.Ignored = true).Random(5).With(e => e.EpisodeFileId = 0).Build(); var fakeEpisodes = Builder<Episode>.CreateListOfSize(10).All().With(e => e.SeriesId = fakeSeries.SeriesId).With(e => e.Ignored = true).Random(5).With(e => e.EpisodeFileId = 0).Build();
@ -265,7 +300,7 @@ namespace NzbDrone.Core.Test.ProviderTests
{ {
WithRealDb(); WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build(); var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(10) var fakeEpisodes = Builder<Episode>.CreateListOfSize(10)
.All() .All()
@ -293,7 +328,7 @@ namespace NzbDrone.Core.Test.ProviderTests
{ {
WithRealDb(); WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build(); var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(10) var fakeEpisodes = Builder<Episode>.CreateListOfSize(10)
.All() .All()
@ -324,7 +359,7 @@ namespace NzbDrone.Core.Test.ProviderTests
{ {
WithRealDb(); WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build(); var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateListOfSize(5) var fakeSeries = Builder<Series>.CreateListOfSize(5)
.All() .All()
@ -360,7 +395,7 @@ namespace NzbDrone.Core.Test.ProviderTests
{ {
WithRealDb(); WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build(); var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateNew() var fakeSeries = Builder<Series>.CreateNew()
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId) .With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
.With(e => e.SeriesId = 1) .With(e => e.SeriesId = 1)
@ -391,7 +426,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.TheFirst(1) .TheFirst(1)
.With(c => c.Path = path) .With(c => c.Path = path)
.Build(); .Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build(); var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
Db.InsertMany(fakeSeries); Db.InsertMany(fakeSeries);
Db.Insert(fakeQuality); Db.Insert(fakeQuality);
@ -420,7 +455,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.TheFirst(1) .TheFirst(1)
.With(c => c.Path = path) .With(c => c.Path = path)
.Build(); .Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build(); var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
Db.InsertMany(fakeSeries); Db.InsertMany(fakeSeries);
Db.Insert(fakeQuality); Db.Insert(fakeQuality);
@ -449,7 +484,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.TheFirst(1) .TheFirst(1)
.With(c => c.Path = path) .With(c => c.Path = path)
.Build(); .Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build(); var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
Db.InsertMany(fakeSeries); Db.InsertMany(fakeSeries);
Db.Insert(fakeQuality); Db.Insert(fakeQuality);
@ -478,7 +513,7 @@ namespace NzbDrone.Core.Test.ProviderTests
.TheFirst(1) .TheFirst(1)
.With(c => c.Path = path) .With(c => c.Path = path)
.Build(); .Build();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build(); var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
Db.InsertMany(fakeSeries); Db.InsertMany(fakeSeries);
Db.Insert(fakeQuality); Db.Insert(fakeQuality);
@ -499,7 +534,7 @@ namespace NzbDrone.Core.Test.ProviderTests
{ {
WithRealDb(); WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build(); var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2) var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
.All() .All()
@ -528,7 +563,7 @@ namespace NzbDrone.Core.Test.ProviderTests
{ {
WithRealDb(); WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build(); var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2) var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
.All() .All()
@ -557,7 +592,7 @@ namespace NzbDrone.Core.Test.ProviderTests
{ {
WithRealDb(); WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build(); var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2) var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
.All() .All()
@ -584,7 +619,7 @@ namespace NzbDrone.Core.Test.ProviderTests
{ {
WithRealDb(); WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build(); var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2) var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
.All() .All()
@ -613,7 +648,7 @@ namespace NzbDrone.Core.Test.ProviderTests
{ {
WithRealDb(); WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build(); var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build(); var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2) var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
.All() .All()
@ -643,7 +678,7 @@ namespace NzbDrone.Core.Test.ProviderTests
{ {
WithRealDb(); WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build(); var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateListOfSize(10) var fakeSeries = Builder<Series>.CreateListOfSize(10)
.All() .All()
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId) .With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
@ -664,7 +699,7 @@ namespace NzbDrone.Core.Test.ProviderTests
{ {
WithRealDb(); WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build(); var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateListOfSize(10) var fakeSeries = Builder<Series>.CreateListOfSize(10)
.All() .All()
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId) .With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
@ -685,7 +720,7 @@ namespace NzbDrone.Core.Test.ProviderTests
{ {
WithRealDb(); WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build(); var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateListOfSize(10) var fakeSeries = Builder<Series>.CreateListOfSize(10)
.All() .All()
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId) .With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
@ -706,7 +741,7 @@ namespace NzbDrone.Core.Test.ProviderTests
{ {
WithRealDb(); WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build(); var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateListOfSize(10) var fakeSeries = Builder<Series>.CreateListOfSize(10)
.All() .All()
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId) .With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
@ -727,7 +762,7 @@ namespace NzbDrone.Core.Test.ProviderTests
{ {
WithRealDb(); WithRealDb();
var fakeQuality = Builder<QualityProfile>.CreateNew().Build(); var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateListOfSize(10) var fakeSeries = Builder<Series>.CreateListOfSize(10)
.All() .All()
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId) .With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
@ -753,7 +788,7 @@ namespace NzbDrone.Core.Test.ProviderTests
var newMonitored = false; var newMonitored = false;
var newSeasonFolder = false; var newSeasonFolder = false;
var fakeQuality = Builder<QualityProfile>.CreateNew().Build(); var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateListOfSize(1) var fakeSeries = Builder<Series>.CreateListOfSize(1)
.All() .All()
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId) .With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
@ -790,7 +825,7 @@ namespace NzbDrone.Core.Test.ProviderTests
var monitored = true; var monitored = true;
var seasonFolder = true; var seasonFolder = true;
var fakeQuality = Builder<QualityProfile>.CreateNew().Build(); var fakeQuality = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
var fakeSeries = Builder<Series>.CreateListOfSize(2) var fakeSeries = Builder<Series>.CreateListOfSize(2)
.All() .All()
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId) .With(e => e.QualityProfileId = fakeQuality.QualityProfileId)

@ -155,7 +155,7 @@ namespace NzbDrone.Core.Test
var db = TestDbHelper.GetEmptyDatabase(); var db = TestDbHelper.GetEmptyDatabase();
Mocker.SetConstant(db); Mocker.SetConstant(db);
var fakeProfile = Builder<QualityProfile>.CreateNew().Build(); var fakeProfile = Builder<QualityProfile>.CreateNew().With(p => p.Cutoff = QualityTypes.DVD).With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD }).Build();
//Act //Act
Mocker.Resolve<QualityProvider>().Add(fakeProfile); Mocker.Resolve<QualityProvider>().Add(fakeProfile);

Loading…
Cancel
Save