1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-26 17:47:08 +00:00

Fixed broken tests

This commit is contained in:
Mark McDowall 2012-10-13 17:54:46 -07:00
parent 92acb4c049
commit 41f70ce7ca
2 changed files with 62 additions and 27 deletions

View file

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using FizzWare.NBuilder;
@ -16,6 +17,19 @@ namespace NzbDrone.Core.Test.ProviderTests
[TestFixture]
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(false)]
public void Add_new_series(bool useSeasonFolder)
@ -25,7 +39,12 @@ public void Add_new_series(bool useSeasonFolder)
Mocker.GetMock<ConfigProvider>()
.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);
@ -96,7 +115,12 @@ public void Get_series_by_id()
.With(c => c.EpisodeFileCount = 0)
.With(c => c.SeasonCount = 0)
.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(fakeQuality);
@ -121,7 +145,12 @@ public void Find_series_by_cleanName_mapped()
.With(c => c.QualityProfileId = 1)
.With(c => c.CleanTitle = "laworder")
.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);
Db.Insert(fakeQuality);
@ -168,6 +197,8 @@ public void find_series_match(string title, string searchTitle)
var fakeQuality = Builder<QualityProfile>.CreateNew()
.With(c => c.QualityProfileId = fakeSeries.QualityProfileId)
.With(p => p.Cutoff = QualityTypes.DVD)
.With(p => p.Allowed = new List<QualityTypes> { QualityTypes.SDTV, QualityTypes.DVD })
.Build();
Db.Insert(fakeSeries);
@ -197,7 +228,11 @@ public void is_monitored()
.With(c => c.SeriesId = 11)
.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
var provider = Mocker.Resolve<SeriesProvider>();
@ -211,7 +246,7 @@ public void Get_Series_With_Count()
{
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 fakeEpisodes = Builder<Episode>.CreateListOfSize(10)
.All().With(e => e.SeriesId = fakeSeries.SeriesId)
@ -242,7 +277,7 @@ public void Get_Series_With_Count_AllIgnored()
{
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 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 @@ public void Get_Series_With_Count_AllDownloaded()
{
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 fakeEpisodes = Builder<Episode>.CreateListOfSize(10)
.All()
@ -293,7 +328,7 @@ public void Get_Series_With_Count_Half_Ignored()
{
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 fakeEpisodes = Builder<Episode>.CreateListOfSize(10)
.All()
@ -324,7 +359,7 @@ public void Get_Series_should_not_return_series_that_do_not_have_info_synced_yet
{
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)
.All()
@ -360,7 +395,7 @@ public void Get_Single_Series()
{
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)
.With(e => e.SeriesId = 1)
@ -391,7 +426,7 @@ public void SeriesPathExists_exact_match()
.TheFirst(1)
.With(c => c.Path = path)
.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.Insert(fakeQuality);
@ -420,7 +455,7 @@ public void SeriesPathExists_match()
.TheFirst(1)
.With(c => c.Path = path)
.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.Insert(fakeQuality);
@ -449,7 +484,7 @@ public void SeriesPathExists_match_alt()
.TheFirst(1)
.With(c => c.Path = path)
.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.Insert(fakeQuality);
@ -478,7 +513,7 @@ public void SeriesPathExists_match_false()
.TheFirst(1)
.With(c => c.Path = path)
.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.Insert(fakeQuality);
@ -499,7 +534,7 @@ public void Get_Series_NextAiring_Today()
{
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 fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
.All()
@ -528,7 +563,7 @@ public void Get_Series_NextAiring_Tomorrow_Last_Aired_Yesterday()
{
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 fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
.All()
@ -557,7 +592,7 @@ public void Get_Series_NextAiring_Unknown()
{
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 fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
.All()
@ -584,7 +619,7 @@ public void Get_Series_NextAiring_1_month()
{
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 fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
.All()
@ -613,7 +648,7 @@ public void Get_Series_NextAiring_skip_ignored()
{
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 fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
.All()
@ -643,7 +678,7 @@ public void SearchForSeries_should_return_results_that_start_with_query()
{
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)
.All()
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
@ -664,7 +699,7 @@ public void SearchForSeries_should_return_results_that_contain_the_query()
{
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)
.All()
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
@ -685,7 +720,7 @@ public void SearchForSeries_should_return_results_that_end_with_the_query()
{
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)
.All()
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
@ -706,7 +741,7 @@ public void SearchForSeries_should_not_return_results_that_do_not_contain_the_qu
{
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)
.All()
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
@ -727,7 +762,7 @@ public void SearchForSeries_should_return_results_when_query_has_special_charact
{
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)
.All()
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
@ -753,7 +788,7 @@ public void UpdateFromMassEdit_should_only_update_certain_values()
var newMonitored = 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)
.All()
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)
@ -790,7 +825,7 @@ public void UpdateFromMassEdit_should_only_update_changed_values()
var monitored = 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)
.All()
.With(e => e.QualityProfileId = fakeQuality.QualityProfileId)

View file

@ -155,7 +155,7 @@ public void SetupInitial_should_skip_if_any_profile_exists()
var db = TestDbHelper.GetEmptyDatabase();
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
Mocker.Resolve<QualityProvider>().Add(fakeProfile);